javascript - CSS selectors for two different div's -


i wondering if possible style div if other div contains specific class?! know can done jquery wondering if can done css aswell.

let's have

<div class="stickywrap sticky"></div> <div class="checkout "></div> 

is possible style checkout when stickwrap contains class sticky?

i tried like:

.stickywrap[class*="sticky"] + .checkout{   background-color: #1f6053;  } 

that obvious doesn't work.

just chain classnames in selector.

.stickywrap.sticky + .checkout {    background:red;  }
<div class="stickywrap">not sticky</div>  <div class="checkout ">checkout</div>    <div class="stickywrap sticky">sticky</div>  <div class="checkout ">checkout</div>

note: think selector wanted was:

.stickywrap[class$="sticky"] + .checkout{   background-color: #1f6053;  } 

this find parent elements have both .stickywrap and classes end in "sticky"...otherwise it's broad.

jsfiddle demo


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -