开发者

Set different background image dependent on match of child element

开发者 https://www.devze.com 2022-12-21 17:23 出处:网络
Can I set a different background-image CSS attribute to my <BODY> tag depending on successful match of a found child <div class=\"template\" /> element?

Can I set a different background-image CSS attribute to my <BODY> tag depending on successful match of a found child <div class="template" /> element?

I know of the CSS selector BODY>.template but that alters the template class where an immediate parent match of BODY exists, I want to control 开发者_Go百科BODY if template exists as a child.

I would like to do this purely in CSS, not with any jQuery or anything, thanks.


Unfortunately that's not possible with pure CSS. You can't influence a parent element based on a child element. The Cascading in CSS only goes in one direction. :)

If you can you should add a different id or class to <body> to do this.

0

精彩评论

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