在我的表单中,我有三个输入字段:姓名、电子邮件和手机号码,但是我想要更改输入文本框的样式 -
在我的表格里,我有三个输入框分别对应姓名、邮箱和手机号。但是我希望将它们的文本框样式修改为 -
name : _____________
email: _____________
mob : _____________
input[type=text] {
background: transparent;
border: none;
border-bottom: 1px solid #000000;
}
从这里开始,您可以使用填充来定位实际的文本输入位置。例如,要使线条在实际输入区域两侧延伸5像素:
padding: 2px 5px;
input{
background:url(bg-dot.jpg) repeat-x center bottom;
border:none;
padding:2px 2px;
}
background-position
。另外,IE6已经过时了,请让它保持这种状态,为了世界上所有美好的事物,请这么做。 - Matthew Scharley您可以随心所欲地样式化输入框。请查看 Codepen,我已经使用 CSS 样式化了一个输入框。
HTML -
<div class="input__box">
<input type="text" placeholder="Enter Some Text Here...">
</div>
.input__box{
width:800px;
height: 200px;
margin:0 auto;
background-color: #f2f2f2;
display: grid;
place-items:center;
position: relative;
}
.input__box input{
all:unset;
width:600px;
height:60px;
border:1px solid grey;
padding-left:55px;
font-size:18px;
color:#333;
font-family:sans-serif;
position:relative;
}
input:focus{
outline:1px solid royalblue;
border:none;
}
input[type="text"]::-webkit-input-placeholder { /* Chrome/Opera/Safari */
font-size:18px;
color:dimgrey;
font-family:sans-serif;
}
input[type="text"]::-moz-placeholder{ /* Firefox 19+ */
font-size:18px;
color:dimgrey;
font-family:sans-serif;
}
input[type="text"]:-moz-placeholder{ /* Firefox 18- */
font-size:18px;
color:dimgrey;
font-family:sans-serif;
}
input[type="text"]:-ms-input-placeholder{ /* IE 10+ */
font-size:18px;
color:dimgrey;
font-family:sans-serif;
}
input[type="text"]::placeholder {
font-size:18px;
color:dimgrey;
font-family:sans-serif;
}
.input__box::before{
content: "☎";
position: absolute;
left: calc(50% - 327px);
top:calc(50% - 30px);
color: #333;
font-weight: bold;
font-size:40px;
padding:0 10px;
}
.input__box {
width: 800px;
height: 200px;
margin: 0 auto;
background-color: #f2f2f2;
display: grid;
place-items: center;
position: relative;
}
.input__box input {
all: unset;
width: 600px;
height: 60px;
border: 1px solid grey;
padding-left: 55px;
font-size: 18px;
color: #333;
font-family: sans-serif;
position: relative;
}
input:focus {
outline: 1px solid royalblue;
border: none;
}
input[type="text"]::-webkit-input-placeholder {
/* Chrome/Opera/Safari */
font-size: 18px;
color: dimgrey;
font-family: sans-serif;
}
input[type="text"]::-moz-placeholder {
/* Firefox 19+ */
font-size: 18px;
color: dimgrey;
font-family: sans-serif;
}
input[type="text"]:-moz-placeholder {
/* Firefox 18- */
font-size: 18px;
color: dimgrey;
font-family: sans-serif;
}
input[type="text"]:-ms-input-placeholder {
/* IE 10+ */
font-size: 18px;
color: dimgrey;
font-family: sans-serif;
}
input[type="text"]::placeholder {
font-size: 18px;
color: dimgrey;
font-family: sans-serif;
}
.input__box::before {
content: "☎";
position: absolute;
left: calc(50% - 327px);
top: calc(50% - 30px);
color: #333;
font-weight: bold;
font-size: 40px;
padding: 0 10px;
}
<div class="input__box">
<input type="text" placeholder="Enter Some Text Here...">
</div>
border: 1px solid black;
float: left;
margin: 0;
padding: 0;
border-top: 0px;
border-left: 0px;
border-right: 0px;
你想只显示底部,因此应用CSS以禁用其他三个部分...
应用类似以下的CSS:
border: 1px solid black;
float: left;
margin: 0;
padding: 0;
border-top: 0px;
border-left: 0px;
border-right: 0px;
适用于所有
.mainInput {
width: 100%;
border: none;
border-bottom: 1px solid #474747;
color: rgba(0, 0, 0, 0.4);
background: transparent;
font-size: 16px;
padding-bottom: 1.25rem;
outline: none;
}
.mainInput::placeholder {
text-overflow: ellipsis !important;
color: rgba(0, 0, 0, 0.4);
}