-1

I want to target col-sm-5 col-md-5 class for apply custom css:

<div class="container extra-info">
   <div class="row">
     <div class="col-sm-5 col-md-5">
     </div>
   </div>
</div>
3
  • Wasn't your question about using target? Why did you change it? Commented May 20, 2018 at 12:41
  • i have only above coding format can not add external id so using class i need solution Commented May 20, 2018 at 12:42
  • I have updated the answer. Commented May 20, 2018 at 12:45

2 Answers 2

2

Thats how i will select the first .col-sm-5

.extra-info:first-child > .row > .col-sm-5 {
  background-color: red;
}
<div class="container extra-info">
   <div class="row">
     <div class="col-sm-5 col-md-5">
     test
     </div>
   </div>
</div>

<div class="container extra-info">
   <div class="row">
     <div class="col-sm-5 col-md-5">
     test
     </div>
   </div>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

thanks friend its works for me
0

You need to have an ID to apply target. So add an id first:

<div class="container extra-info">
   <div class="row">
     <div class="col-sm-5 col-md-5" id="target">
     </div>
   </div>
</div>

Now you can use the pseudo selector:

#target::target {
  background: #f00;
}

You just need to navigate to: /path/to/file#target.

If you just want to target that element, it's as simple as:

  • Adding a new class.
  • Adding a new id.

So, for either, try to do the following:

Solution using class

<div class="container extra-info">
   <div class="row">
     <div class="col-sm-5 col-md-5 target">
     </div>
   </div>
</div>

And use the CSS:

.target {
  background: #f00;
}

Solution using id

<div class="container extra-info">
   <div class="row">
     <div class="col-sm-5 col-md-5" id="target">
     </div>
   </div>
</div>

And use the CSS:

#target {
  background: #f00;
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.