html - 设置边框顶部宽度 : 0px; on Input changes whole border appearance

标签 html css

我想在彼此下面显示两个输入字段,没有边距,没有填充,也没有双边框(所以它看起来很像一个普通表格,只有一个分隔符 每个字段之间的线)。

去除边距很容易(margin-top: 0px; margin-bottom: 0px;),但是当我尝试使用 border-top-width: 0px 去除顶部边框时;,整个输入框的外观变成了浅灰色,尺寸也变大了。这种效果发生在所有浏览器中。

举个例子: HTML

<div class="test">
    <input type="text" value="Test" />
    <br />
    <input type="text" value="Test" />
</div>

CSS:

input {
    margin-top: 0px;
    margin-bottom: 0px;
}
.test input {
    border-top-width: 0px;
}
.test input:first-child {
    border-top-width: 2px;
}

fiddler :http://fiddle.jshell.net/32een/1/

解释我想要什么的图像:

enter image description here

最佳答案

试试这个:

.test input {
    border-top: 0;
}
.test input:first-child {
    border-top: 2px solid #ccc;
}

此外,在您的代码中,您可以将“0px”替换为“0”以进行优化。

关于html - 设置边框顶部宽度 : 0px; on Input changes whole border appearance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14985503/

相关文章:

javascript - 动态 HTML img 上的绑定(bind)/实时加载事件不起作用

css - 并排不同的列表html5

javascript - 按字母顺序对多级列表菜单进行排序

Javascript 动态添加 HTML

html - 如何使倾斜的边框在不同的屏幕尺寸 CSS3 中保持在正确的位置

html - 如果 div 具有相对位置元素,是否可以增长它?

javascript - 使用 Javascript 通过 PHP 变量设置 HTML Date 元素的值

html - 如何使容器 div 垂直拉伸(stretch)以适应 IE 中的表格?

javascript - slider 中的图像数 (1/10)

css - 如何覆盖 css 值?