是否有更简洁的方法来编写相同的 css 假设 input name f1 to f7
都像第一行一样 type=text
?
谢谢
#tform input[type="text"] { -moz-border-radius:6px; border: 1px solid green; } #tform input[name="f1"], #tform input[name="f2"], #tform input[name="f3"], #tform input[name="f4"], #tform input[name="f5"] { width:40%; } #tform input[name="f6"] { width:80%; display:block; } #tform input[name="f7"] { width:80%; }
我的问题实际上是我有 3 个额外的输入:name f8, f8, f10
,还有 type=text
我让它们自然地设置宽度而不用 宽度:%;
。
我考虑过将 40% 放入第一行并让其余部分覆盖它,但随后那些额外的 3 个将默认占用 40%。
最佳答案
考虑改为给 f1-f5 上课?它可能是几个额外的 HTML 字节,但您会得到更清晰的 CSS。
.yourClass { width: 40%; }
关于css - 能否改进此 CSS 语法,使其更有条理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1593875/