开发者

CSS inheritance: applying selector for itself and every descendant

Get a custom user CSS and type thi开发者_如何学Pythons

.answered-accepted {
  color: white !important;
  background: #090 !important;
}

Now go to answers.unity3d and look for an accepted answer. The design looks bad, because the <strong> in there overrides the customization. The fix I've found is this:

.answered-accepted, .answered-accepted * {
  color: white !important;
  background: #090 !important;
}

Now it looks fine on the website, but the code looks ugly!! How can I do this without repeating the class name?


How about

.answered-accepted strong {
  font-weight: normal;
}


.answered-accepted strong {
  font-weight: inherit;
}

This will make the <strong> inherit the font-weight from the most direct parent so you can keep all the data in one place. You can inherit any other properties you want the <strong> to take from .answer-accepted.

Only problem is that IE7 and earlier don't support it, so you may still need your hack....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜