Reputation: 2743
I'm wondering if there is a pure CSS way to add a class to elements of another class. The problem I'm trying to solve is below, which is also an example.
Using bootstrap, I have a number of elements that look like this:
<li class="nav-item">
<a class="nav-link" href="#">Law</a>
</li>
What I would like to do is add the pull-right
class to each element with the class nav-item
(I think), in order to make the nav items all float to the right.
Is there a pure CSS way to do this? I think the answer is no, at least without LESS/SASS/JS, but I'd love to be disabused of that notion.
Upvotes: 0
Views: 166
Reputation:
No, if you are wanting to add a class to the CSS you would need to use either JavaScript or Jquery. I would recommend Jquery because IMO it is a little easier to work with when adding classes.
Or you could just add the class to each nav-item:
<li class="nav-item pull-right">
Upvotes: 1