内联css是否会覆盖样式表css文件?(Does inline css override a stylesheet css file?)

编程入门 行业动态 更新时间:2024-10-27 01:24:41
内联css是否会覆盖样式表css文件?(Does inline css override a stylesheet css file?)

我试图对同一类的4个div(彼此相邻)进行样式设置, margin-right为35px以均匀分割它们,除了最后一个div以外,所以它不会为已分配给30px margin添加额外的边距包装的右侧。

现在,我不是编码方面的专家,所以我可能在这里是错误的,但我认为我可以添加margin-right: 0; 内联到最后一个div来覆盖样式表中的属性值35px 。

这会工作吗? 还是有不同的解决方案,我没有看到?

编辑:谢谢大家,最后一个孩子伪选择器工作! :-)

I'm trying to style 4 divs (next to each other) of the same class with a margin-right of 35px to divide them evenly, except for the last div so it doesn't add extra margins to the 30px margin already assigned to the right side of the wrapper.

Now, I'm not an expert at coding yet so I might be wrong here, but I was thinking that I could add margin-right: 0; inline to the last div to override the property value 35px in my stylesheet.

Would this work? Or is there a different solution that I'm not seeing?

Edit: thanks to you all, the last-child pseudo selector worked! :-)

最满意答案

这将覆盖风格和工作。 但是另一种解决方案是使用工作表中的:last-child伪选择器。

欲了解更多关于last-child : http : //www.w3schools.com/cssref/sel_last-child.asp

This would override the style and work. But another solution would be to use the :last-child pseudo selector in the sheet.

For more on last-child: http://www.w3schools.com/cssref/sel_last-child.asp

更多推荐

本文发布于:2023-07-30 11:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1337886.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内联   是否会   样式表   文件   css

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!