html - is it possible to reference a css property from another element? -


i introducing myself in css, it's structure of javascript object, somehow in code want use class of .blm height property on keyframes' border-bottom-width property, code , demo

.blm {    display: inline-block;    background-color: pink;    border: solid black 1px;    height: 300px;    width: 100px;    animation: kk 3s linear 0s 2 normal;    box-sizing: border-box;  }  @keyframes kk {    0% {      border-bottom-color: red;      border-bottom-width: 0px;    }    100% {      border-bottom-color: red;      border-bottom-width: 300px;/* want reference on .blm height property , maybe use percentage in it*/    }  }  .blm2 {    border: sold black 1px;    width: 100px;    height: 100px;/* here, if isn't child element */    background: green;  }
<div class="blm">    blm  </div>  <div class="blm2">    blm2  </div>

the way this, currently, use css variables (which not supported in ie or edge):

:root {   --shared-height: 300px; }  .blm {   display: inline-block;   background-color: pink;   border: solid black 1px;   height: var(--shared-height);   width: 100px;   animation: kk 3s linear 0s 2 normal;   box-sizing: border-box; }  @keyframes kk {   0% {     border-bottom-color: red;     border-bottom-width: 0px;   }   100% {     border-bottom-color: red;     height: var(--shared-height);     /* want reference  on .blm height property , maybe use percentage in it*/   } }  /* provides default styles element unless    subsequent selector more specific: */ .blm2 {   border: sold black 1px;   width: 100px;   background: green;   height: var(--shared-height); }  /* if .blm2 element has specific ancestor    (the obviously-named '.ancestorelementselector')    height used: */ .ancestorelementselector .blm2 {   height: 100px;   /* here, if isn't child element */ } 

css pre-processors, such sass , less (among others, presumably), allow use of variables, compile regular css after they've been compiled.

these may worth exploring, particularly if edge or ie required, since i've never felt need use them can't recommend them explicitly.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -