所以我想自定义几个输入。我试过了,它工作得很好:
<!DOCTYPE html>
<html>
<head>
<style>
input[id=a]:focus {
width: 250px;
}
</style>
</head>
<body>
<h1>The width Property</h1>
Searcha: <input type="text" name="search" id="a">
Searchb: <input type="text" name="search" id="b">
</body>
</html>
但是,我想在输入上放入更多的ids。有可能吗?
//try
input[id=a b]:focus {
width: 250px;
}
发布于 2019-01-10 12:09:47
没有一个选择器可以针对单个属性的多个值。
不幸的是,你需要一个逗号分隔的带有不同值的整个选择器列表,如下所示:
input[id="a"]:focus, input[id="b"]:focus {
width: 250px;
}
在这种情况下,一个类会更有好处。
发布于 2019-01-10 12:03:07
您可以像这样链接css中的选择器:
#foo, #bar {
color: red
}
然而,如果你有5个以上的if,这可能会变得有点乏味,在这一点上,最好使用一个类:
HTML:
<input class="search-input" />
<input class="search-input" />
CSS:
.search-input {
color: red
}
发布于 2019-01-10 12:02:18
#a, #b {}
事情真的就这么简单。
https://stackoverflow.com/questions/54128232
复制相似问题