html - pure css conditionally change background-color of body -
this question has answer here:
- is there css parent selector? 24 answers
is possible in pure css change background-color
of body
element depending of id (or class) of first div inside body
?
for instance :
<body> // background-color black <div id="abc"> ... </div> </body> <body> // background-color red <div id="cde"> ... </div> </body>
no there's no way of doing purely in css. you'll need javascript/jquery that, change body background it.
if ($('#abc')[0]) { $('body').css('background','black') } if ($('#cde')[0]) { $('body').css('background','red') }
Comments
Post a Comment