我想为结帐表单字段实施CSS“浮动标签”,以获得更好的用户体验。为此,必须紧跟。
我似乎找不到在woocommerce中更改订单的简单方法。
任何提示都非常感谢。
仅CSS浮动标签
HTML:
<div class="field-container">
<input type="text" class="field" required placeholder="First name"/>
<label class="floating-label">First name</label>
<div class="field-underline"></div>
</div>
<div class="field-container">
<input type="text" class="field" required placeholder="Last name"/>
<label class="floating-label">Last name</label>
<div class="field-underline"></div>
</div>
CSS:
.field-container {
position: relative;
width: 200px;
margin-top:20px;
font-family: 'Roboto', sans-serif;
}
.field {
display:block;
width:100%;
padding:15px 10px 0;
border:none;
font-size:14px;
}
.field:focus {
outline: 0;
}
.floating-label {
position:absolute;
pointer-events:none;
top: 5px;
left:10px;
font-size: 10px;
opacity:0;
background-color: white;
padding: 0 2px;
-webkit-transition: 0.2s ease-in-out;
transition: 0.2s ease-in-out;
}
.field:valid + .floating-label {
opacity:1;
top:-5px;
color: #9e9e9e;
}
.field:focus + .floating-label {
color: #03a9f4;
}
.field-underline {
position:absolute;
top:0;
left:0;
right:0;
bottom:-5px;
border:1px solid #9e9e9e;
z-index: -1;
padding:10px 10px 0;
}
.field:focus + .floating-label + .field-underline {
border-color:#03a9f4;
}