如何从这个 css 类选择器声明中干燥(删除冗余)?
我:
.sketch_img_thumb_box .title{
opacity: 0.1;
}
.sketch_img_thumb_box:hover .title{
opacity: 1;
}
.sketch_img_thumb_box .artist{
opacity: 0.1;
}
.sketch_img_thumb_box:hover .artist{
opacity: 1;
}
.sketch_img_thumb_box .rating_bar {
opacity: 0.1;
}
.sketch_img_thumb_box:hover .rating_bar {
opacity: 1;
}
我把它归结为:
.sketch_img_thumb_box .title, .sketch_img_thumb_box .artist, .sketch_img_thumb_box .rating_bar{
opacity: 0.1;
}
.sketch_img_thumb_box:hover .title, .sketch_img_thumb_box:hover .artist, .sketch_img_thumb_box:hover .rating_bar{
opacity: 1;
}
我们可以进一步优化吗?
I have:
.sketch_img_thumb_box .title{
opacity: 0.1;
}
.sketch_img_thumb_box:hover .title{
opacity: 1;
}
.sketch_img_thumb_box .artist{
opacity: 0.1;
}
.sketch_img_thumb_box:hover .artist{
opacity: 1;
}
.sketch_img_thumb_box .rating_bar {
opacity: 0.1;
}
.sketch_img_thumb_box:hover .rating_bar {
opacity: 1;
}
I took it down to:
.sketch_img_thumb_box .title, .sketch_img_thumb_box .artist, .sketch_img_thumb_box .rating_bar{
opacity: 0.1;
}
.sketch_img_thumb_box:hover .title, .sketch_img_thumb_box:hover .artist, .sketch_img_thumb_box:hover .rating_bar{
opacity: 1;
}
Can we optimize further?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样写
css:
html:
因为如果你给
parent
赋予opacity
,那么children
会自动获得不透明度。检查小提琴 http://jsfiddle.net/sandeep/axuxT/4/
&如果您不想给其他
children
赋予opacity
,请写下以下内容:检查小提琴 http://jsfiddle.net/sandeep/RqP6p/
write like this
css:
html:
because if you give
opacity
theparent
thenchildren
automatically get the opacity.check the fiddle http://jsfiddle.net/sandeep/axuxT/4/
& If there are others
children
which you didn't want to giveopacity
then write this:Check the fiddle http://jsfiddle.net/sandeep/RqP6p/