Html 文本输入大小的CSS问题-可能的继承问题
我正在尝试创建一个带有文本输入的表,但在使文本框大小正确时遇到了一些问题。当复制到现有项目时,文本框四周将大4倍。这是一个唯一的名称,但它仍然继承属性,我不知道如何避免这种情况。表格尺寸正确,只是输入不正确 这是CSSHtml 文本输入大小的CSS问题-可能的继承问题,html,css,Html,Css,我正在尝试创建一个带有文本输入的表,但在使文本框大小正确时遇到了一些问题。当复制到现有项目时,文本框四周将大4倍。这是一个唯一的名称,但它仍然继承属性,我不知道如何避免这种情况。表格尺寸正确,只是输入不正确 这是CSS .medium_input{ display: block; width:90%; height:30px; font-size:12px; padding: 0; margin: 0; } .left_half { wi
.medium_input{
display: block;
width:90%;
height:30px;
font-size:12px;
padding: 0;
margin: 0;
}
.left_half {
width: 49%;
float: left;
}
.g_info_table {
width:100%;
margin-bottom: 0;
}
.g_info_table tr td {
vertical-align: middle;
height: 40px;
border-bottom: none;
}
.g_info_table tr:nth-child(even) {
background-color: #FFF;
}
这是HTML(我正在使用knockout)
名字
姓
地址
城市
在加载其他表格样式之前,我会在表格容器的左半部分添加一个重置:
.left_half * {
margin: 0;
padding: 0;
border: none;
}
.medium_input{
display: block;
width:90%;
height:30px;
font-size:12px;
padding: 0;
margin: 0;
}
.left_half {
width: 49%;
float: left;
}
.g_info_table {
width:100%;
margin-bottom: 0;
}
.g_info_table tr td {
vertical-align: middle;
height: 40px;
border-bottom: none;
}
.g_info_table tr:nth-child(even) {
background-color: #FFF;
}
我不是专家,但当您无法控制继承时,您就是这么做的。如果您检查ff/chrome中的元素,它是否会提示您从何处继承不需要的CSS?您是否正在使用重置(尽管这可能不是问题的原因)?有一点是,您没有考虑边界线,它等于每边1像素。@JuanGonzales我说的是边界内。即使包括边界,仍然有2px的差异。你应该指定4px比什么大。您应该描述发生了什么,而不是假设继承是原因(很可能是错误的)。听起来您在代码中使用的上下文根本没有在问题中公开,这会导致一些CSS设置被覆盖。
.left_half * {
margin: 0;
padding: 0;
border: none;
}
.medium_input{
display: block;
width:90%;
height:30px;
font-size:12px;
padding: 0;
margin: 0;
}
.left_half {
width: 49%;
float: left;
}
.g_info_table {
width:100%;
margin-bottom: 0;
}
.g_info_table tr td {
vertical-align: middle;
height: 40px;
border-bottom: none;
}
.g_info_table tr:nth-child(even) {
background-color: #FFF;
}