如何使用其占位符动画创建表单?

时间:2017-02-15 04:15:08

标签: css

我正在尝试创建一个类似于SEND GRID的表单 我不确定他们使用了什么技术。 Google向我提供了有关MaterialsCSS的一些信息。使用好吗?

任何人都可以指导我吗?

1 个答案:

答案 0 :(得分:1)

纯CSS3会对你有所帮助!



.input {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 1em;
  max-width: 350px;
  width: calc(100% - 2em);
  vertical-align: top;
}
.input__field {
  position: relative;
  display: block;
  float: right;
  padding: 0.8em;
  width: 60%;
  border: none;
  border-radius: 0;
  background: #f0f0f0;
  color: #aaa;
  font-weight: 400;
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-appearance: none;
  /* for box shadows to show on iOS */
}
.input__field:focus {
  outline: none;
}
.input__label {
  display: inline-block;
  float: right;
  padding: 0 1em;
  width: 40%;
  color: #696969;
  font-weight: bold;
  font-size: 70.25%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.input__label-content {
  position: relative;
  display: block;
  padding: 1.6em 0;
  width: 100%;
}
.graphic {
  position: absolute;
  top: 0;
  left: 0;
  fill: none;
}
.icon {
  color: #ddd;
  font-size: 150%;
}
/* Nariko */

.input--nariko {
  overflow: hidden;
  padding-top: 2em;
}
.input__field--nariko {
  width: 100%;
  background: transparent;
  opacity: 0;
  padding: 0.35em;
  z-index: 100;
  color: #f18292;
}
.input__label--nariko {
  width: 100%;
  bottom: 0;
  position: absolute;
  pointer-events: none;
  text-align: left;
  color: #8E9191;
  padding: 0 0.5em;
}
.input__label--nariko::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 4em;
  top: 100%;
  left: 0;
  background: #fff;
  border-top: 4px solid #9B9F9F;
  -webkit-transform: translate3d(0, -3px, 0);
  transform: translate3d(0, -3px, 0);
  -webkit-transition: -webkit-transform 0.4s;
  transition: transform 0.4s;
  -webkit-transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
  transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
}
.input__label-content--nariko {
  padding: 0.5em 0;
  -webkit-transform-origin: 0% 100%;
  transform-origin: 0% 100%;
  -webkit-transition: -webkit-transform 0.4s, color 0.4s;
  transition: transform 0.4s, color 0.4s;
  -webkit-transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
  transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
}
.input__field--nariko:focus,
.input--filled .input__field--nariko {
  cursor: text;
  opacity: 1;
  -webkit-transition: opacity 0s 0.4s;
  transition: opacity 0s 0.4s;
}
.input__field--nariko:focus + .input__label--nariko::before,
.input--filled .input__label--nariko::before {
  -webkit-transition-delay: 0.05s;
  transition-delay: 0.05s;
  -webkit-transform: translate3d(0, -3.3em, 0);
  transform: translate3d(0, -3.3em, 0);
}
.input__field--nariko:focus + .input__label--nariko .input__label-content--nariko,
.input--filled .input__label-content--nariko {
  color: #6B6E6E;
  -webkit-transform: translate3d(0, -3.3em, 0) scale3d(0.81, 0.81, 1);
  transform: translate3d(0, -3.3em, 0) scale3d(0.81, 0.81, 1);
}

<section class="content bgcolor-7">
  <h2>Input Custom Design</h2>
  <span class="input input--nariko">
					<input class="input__field input__field--nariko" type="text" id="input-20" />
					<label class="input__label input__label--nariko" for="input-20">
						<span class="input__label-content input__label-content--nariko">Username</span>
  </label>
  </span>
  <span class="input input--nariko">
					<input class="input__field input__field--nariko" type="text" id="input-21" />
					<label class="input__label input__label--nariko" for="input-21">
						<span class="input__label-content input__label-content--nariko">Website</span>
  </label>
  </span>
  <span class="input input--nariko">
					<input class="input__field input__field--nariko" type="text" id="input-22" />
					<label class="input__label input__label--nariko" for="input-22">
						<span class="input__label-content input__label-content--nariko">Invitation Code</span>
  </label>
  </span>
</section>
&#13;
&#13;
&#13;

只需HTML5,CSS3和现代浏览器试试这个&amp;尽可能编辑......