CSS * {margin: 0;padding: 0;} 覆盖
大家好,我需要一些帮助来弄清楚如何覆盖我的 css 中的“* {margin: 0;padding: 0;}”。
原因是我有这个 css:
.postcomments { width: 547px; padding: 5px 5px 5px 5px; margin: 0 0 5px 0;}
.postcomments a { text-decoration: underline;}
.postcomments ul { margin: 0; padding: 0; list-style-type: none;}
.postcomments ul li { width: 547px; margin: 0 0 5px 0; padding: 0; list-style-type: none;}
.postcomments .right { color: #474747; font-size: 11px; background: #fff url('http://www.nextbowluser.com/img/ucBG.gif') no-repeat top left; line-height: 17px; padding: 5px 0 0 0; width: 430px; position: relative; float: right; min-height: 50px;}
.postcomments .right .bottom { padding: 0 5px 15px 5px; background: #fff url('http://www.nextbowluser.com/img/ucBG.gif') no-repeat bottom right; min-height: 50px;}
.postcomments .arrow { left: -15px; top: 20px; position: absolute;}
.avatar { border: none !important;}
.postcomments .left {float: left; margin: 0 7px 0 0;}
.postcomments .gravatar { background: #fff; width: 80px; height: 60px; margin: 0 0px 0 0; padding: 3px;}
.postcomments .name { font-size: 11px; margin: 2px 0 0 0; color: #000;}
.avatar { border: none !important;}
并且它在没有 * {margin: 0;padding: 0;} 的情况下显示得很好:
1st comment
2nd comment
3rd comment
但是,当我将其添加到 CSS 中时,它会使注释堆栈错误:
1st comment
2nd comment
3rd comment
我只会采取出 * {margin: 0;padding: 0;} 但页面上的其他一些内容需要它才能正确显示。所以我的问题是,如何覆盖页面的评论部分的 {margin: 0;padding: 0;} ?
谢谢! :o)
大卫
更新: 出色地。仍然无法正确获取。去掉整个网站的边距:0px - 它使网站看起来很糟糕。如果我必须向页面的每个元素添加 margin: 0px 以使其看起来像带有 * 的那样,那就不好了。我仍然只需要一些东西来绕过 .postcomments 部分,仅此而已。
Hey all, i am in need of some help with figuring out how to override the "* {margin: 0;padding: 0;}" in my css.
The reason why is that i have this css:
.postcomments { width: 547px; padding: 5px 5px 5px 5px; margin: 0 0 5px 0;}
.postcomments a { text-decoration: underline;}
.postcomments ul { margin: 0; padding: 0; list-style-type: none;}
.postcomments ul li { width: 547px; margin: 0 0 5px 0; padding: 0; list-style-type: none;}
.postcomments .right { color: #474747; font-size: 11px; background: #fff url('http://www.nextbowluser.com/img/ucBG.gif') no-repeat top left; line-height: 17px; padding: 5px 0 0 0; width: 430px; position: relative; float: right; min-height: 50px;}
.postcomments .right .bottom { padding: 0 5px 15px 5px; background: #fff url('http://www.nextbowluser.com/img/ucBG.gif') no-repeat bottom right; min-height: 50px;}
.postcomments .arrow { left: -15px; top: 20px; position: absolute;}
.avatar { border: none !important;}
.postcomments .left {float: left; margin: 0 7px 0 0;}
.postcomments .gravatar { background: #fff; width: 80px; height: 60px; margin: 0 0px 0 0; padding: 3px;}
.postcomments .name { font-size: 11px; margin: 2px 0 0 0; color: #000;}
.avatar { border: none !important;}
and it displays just fine WITHOUT the * {margin: 0;padding: 0;}:
1st comment
2nd comment
3rd comment
However, when i add that to the CSS, it makes the comments stack wrong:
1st comment
2nd comment
3rd comment
I would just take out the * {margin: 0;padding: 0;} but some other things on the page needs that in order for that to be displayed correctly. So my question is, how can i override the {margin: 0;padding: 0;} for just that postcomments part of the page?
Thanks! :o)
David
UPDATE:
Well. still can not get it correctly. After taking out the margin: 0px for the whole site- it makes the site look terrible. And if i have to add margin: 0px to every element to the page to make it look like it would with the * then thats not good. I still just need something to bypass it for the .postcomments part and thats it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你尝试过 !important 吗?
我使用的是 15px,但你可以使用任何适合你的值
Did you try it with !important?
i am using 15px, but you can use whatever value works for you
也许使用一个可用的reset.css(eric meyer 例如)脚本。然后观察如何构建无序列表。如果有嵌套的 ul,通常每个 ul 都会有一个 margin-left
Maybe use one reset.css (eric meyer e.g.) scripts available. then watch how you build the unordered lists. if there are nested ul you would normally get a margin-left for each ul
.postcomments 应该覆盖 *,因为类更具体。
.postcomments should override *, since a class is more specific.
您需要提供比其他答案包含的内容更具体的内容,
尝试将标签放在类或父标签的前面,
或者如果这不是一个选项,您可以随时求助于
You'll need to provide more specificity then what the other answers contain
try putting the tag infront of the class, or a parent tag
or if that's not an option, you can always resort to