CSS*{margin:0; padding:0;}覆盖

Ste*_*hRT 5 css margin

嘿所有,我需要一些帮助,找出如何在我的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;}
Run Code Online (Sandbox Code Playgroud)

它显示没有*{margin:0; padding:0;}:

 1st comment
 2nd comment
 3rd comment
Run Code Online (Sandbox Code Playgroud)

但是,当我将其添加到CSS时,它会使注释堆栈错误:

 1st comment
    2nd comment
        3rd comment
Run Code Online (Sandbox Code Playgroud)

我会取出*{margin:0; padding:0;},但页面上的其他一些东西需要它才能正确显示.所以我的问题是,如何覆盖{margin:0; padding:0;}只是页面的后续评论部分?

谢谢!:O)

大卫

更新: 嗯.仍然无法正确使用它.取出保证金:整个网站的0px-这使网站看起来很糟糕.如果我必须添加margin:0px到页面的每个元素,使它看起来像*那么那就不好了.我仍然需要一些东西来绕过.postcomments部分,就是这样.

Ger*_*son 3

你尝试过 !important 吗?

.postcomments {
   margin: 15px  !important;
   padding: 15px !important;
}
Run Code Online (Sandbox Code Playgroud)

我使用的是 15px,但你可以使用任何适合你的值

  • 不要使用 `!important` - 而是了解 CSS 特异性 - http://www.w3.org/TR/CSS2/cascade.html#specificity (4认同)