How to use css property under a class only -


i have css property this

:before, :after {  content: '';  display: block;  position: absolute;  box-sizing: border-box; } 

it affecting whole page . need affect type of element under 'togglebox' class . how syntax should .

you need specify class want apply css rules to, so:

.myclass:before, .myclass:after {   content: '';   display: block;   position: absolute;   box-sizing: border-box; } 

you need class="myclass" within elements want style apply to, in case "togglebox". i'm not 100% sure mean "togglebox", assume read below:

<input type="checkbox" name="togglebox" class="myclass"/> 

update: given comment below, looks want apply style children of "togglebox" - pretty easy modification:

.myclass *:before, .myclass *:after {   content: '';   display: block;   position: absolute;   box-sizing: border-box; } 

this css rule apply (hence *) element descendent (immediate children or children , forth).

if want apply rule direct children (and not children of children , forth) use:

.myclass > *:before, .myclass > *:after {   content: '';   display: block;   position: absolute;   box-sizing: border-box; } 

see here more information.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -