The first div element inside a div
the code
<div class="row mgu-w-tdw-brow">
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-widget-teaser-1x1">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-teaser-list-1x1-large">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-teaser-list-1x1-large">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-widget-teaser-1x1">...</div>
</div>
CSS
.mgu-w-tdw-brow div.mgu-w-tdw-box:first-child { border: 2px solid green; }
I would like to approach the first element of "mgu-w-tdw-box" inside the line "mgu-w-tdw-brow". Unfortunately this does not work.
thanks for the help.
+4
3 answers
this is what you need, first select div:first-childand style inside the div
.mgu-w-tdw-brow div:first-child .mgu-w-tdw-box {
border:2px solid green;
}<div class="row mgu-w-tdw-brow">
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-widget-teaser-1x1">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-teaser-list-1x1-large">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-teaser-list-1x1-large">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-widget-teaser-1x1">...</div>
</div>
</div> +5
.mgu-w-tdw-brow [class*="col"]:nth-child(1) .mgu-w-tdw-box{
border:solid 2px #000;
}<div class="row mgu-w-tdw-brow">
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-widget-teaser-1x1">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-teaser-list-1x1-large">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-teaser-list-1x1-large">...</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="mgu-w-tdw-box mgu-widget-teaser-1x1">...</div>
</div>
</div> 0