Css class targeting for specific div only
9 answers
.glyphicon
.glyphicon-ok
.col-1-box + .glyphicon.glyphicon-ok {
border: 1px solid black;
}
<div class="col-sm-1 col-1-box"></div>
<span class="glyphicon glyphicon-ok">Lorem Ipsum</span>
0
, ,
.col-sm-1 span.glyphicon{
color:red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-sm-1 col-1-box">
<span class="glyphicon glyphicon-ok"></span>
, ok ,
0
+ , ( ) . w3schooldoc.
+ .
.parentElement .childElement {
/*Selected Children only*/
background: red;
width: 50px;
height: 50px;
display: inline-block;
}
.notImmediate {
background: blue;
width: 30px;
height: 30px;
}
.childElement + .childElement {
/*Selected immediately after (not inside) */
border-right: 10px solid green;
}
<div class="parentElement">
<div class="childElement">
<div class="notImmediate"></div>
</div>
<div class="childElement"></div>
</div>
0
! :
body {
color: #000;
}
/* scenario 1 */
.col-1-box + .glyphicon.glyphicon-ok {
color: tomato;
}
/* scenario 2 */
.col-1-box .glyphicon.glyphicon-ok {
color: aqua;
}
<h1>Scenario 1</h1>
<div class="col-sm-1 col-1-box"></div>
<span class="glyphicon glyphicon-ok">OK</span>
<hr>
<h1>Scenario 2</h1>
<div class="col-sm-1 col-1-box">
<span class="glyphicon glyphicon-ok">OK</span>
</div>
0