开发者

Css :not style outside element

开发者 https://www.devze.com 2023-03-24 07:58 出处:网络
I want to change the font and bold the <strong> elements that are outside of div.main2, but leave elements inside div.main2 unaffected.

I want to change the font and bold the <strong> elements that are outside of div.main2, but leave elements inside div.main2 unaffected.

I tried usin开发者_开发知识库g :not(.main2) and strong *:not(.main2) but the logic seemed wrong.

The idea is to get something like :

TITULO TITULO

TITULO TITULO

You can check the example here in order to work it out.


UPDATE:

For example in this jsFiddle

Titulo Titulo

Titulo Titulo

Titulo Titulo

Should be like :

Titulo Titulo

Titulo Titulo

Titulo Titulo

in the future can had tables , other divs wit other things...


The easiest way to do it is use two rules instead:

.main strong {
    font-family: Verdana;
    font-weight: bold;
}

.main2 strong {
    font-family: inherit;
    font-weight: inherit;
}

jsFiddle


If you're really looking for a CSS3 solution, you can use this:

.main :not(.main2) strong, .main > strong {
    font-family: Verdana;
    font-weight: bold;
}

0

精彩评论

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