【发布时间】:2015-12-06 01:39:54
【问题描述】:
我正在构建一个注册表单,但在左对齐 input[type="text"] placeholder 和 <select> 元素的“伪”占位符时遇到问题。我希望 input[type="text"] 占位符与 <select> 的“伪”占位符对齐。
我对选择的 HTML 元素使用了“伪”占位符这个词,因为选择的 HTML 元素没有占位符,并且显示的内容而不是占位符是选择中的第一个选项。
您可以在屏幕截图中看到一个 select HTML 元素,其中第一个 <option> 文本为“Country”。还有另一个选择元素,第一个选项文本是“你多久想要你的书?”。
与 input[type="text"] 占位符文本相比,这两个选择元素都有一个缩进,我不能与 input[type="text"] 占位符文本完全左对齐。
input[type="text"].couture-input-underline,
input[type="password"].couture-input-underline,
input[type="number"].couture-input-underline,
select.couture-input-underline
{
width: 300px;
display: block;
font-size: 22px;
border: 0px solid #7f7f7f;
border-bottom-width: 1px;
background: transparent;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-border-radius: 0;
-moz-border-radius: 0;
-o-border-radius: 0;
-ms-border-radius: 0;
border-radius: 0;
padding: 0;
margin:0;
margin-bottom: 10px;
}
.text-match-placeholder{
color: #ACACAC;
}
select option
{
outline: none;
-webkit-appearance: none;
padding: 0;
margin: 0;
}
<select class="couture-input-underline text-match-placeholder">
<option value>Choose</option>
<option>First</option>
<option>Second</option>
</select>
<input type="text" class="couture-input-underline" placeholder="Text Box One" />
【问题讨论】:
-
你想要的可能根本不可能,因为即使你把它们排得很漂亮也只会很漂亮on your browser
-
如上海报所示,选择样式在每个浏览器上的显示方式不同。我会尝试一个 javascript 插件来设置选择的样式,使其在跨浏览器中保持一致。