skip to Main Content

I’m trying to remove classes like class="row" and class="col-md-12" coming from a script file from bootstrap. Can I override and remove it with css?

3

Answers


  1. I don’t believe you can remove a class from the markup with css. You could add an additional class and then make your needed style changes with that more specific selector.

    Login or Signup to reply.
  2. I think that what you want is to hide them by default? If so, create a rule on your css for the mentioned classes.

    .row,  .col-md-12{
     display: none;
    }
    

    Then after, if you want to show them, you can use js to present the elements with that class. Ex:

    document.querySelector('.row').style.display= 'block';
    
    Login or Signup to reply.
  3. You can’t remove the class names via CSS, but you can retrieve all the elements with those class names and remove the class:
    document.querySelectorAll(".row").forEach(r => r.classList.remove("row"));

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search