简体   繁体   中英

How to remove/disable styling on some bootstrap elements

I want to know if it is possible to disable styling on a specific html element.

In my case it is a input text. I cannot resize it. I went through the bootstrap css and found it has padding. I tried to use padding: none and 0 0 0 0 plus !important and it did not work.

Is possible to disable the styling for that specific item?

As of Bootstrap 3, you'd use the list-unstyled class to achieve this.

Example:

<ul class="list-unstyled">
    <li>...</li>
</ul>

Hope this solves your problem.

Yes it is possible. You can achieve it in following way:

  • Load your own stylesheet definition after the bootstrap.css . For your case define input[type=text]{padding:0px;} must call after the bootstrap's css file(s).
  • If you want to use in-line css you can try: <input type="text" style="padding:0px" />

Hope it helps.

Set it in the style of the element in the style attribrute if an item is there it has priority.

Also if you want to be double sure add !important as well

in the 'head' of your HTML change the order of the local css file and bootstrap css, the local css should be the after the bootstrap css:

<head>

   <!-- bootstrap css is the first here -->
   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <!-- bootstrap css is the last -->
    <link rel="stylesheet" href="style.css">


</head>

now if you applied !important in your css it should work.

another solution is to apply your css inline <element style="padding:0"></element>

Would Javascript be of any help to you? If so the . setAttribute native javascript function can help:

http://jsfiddle.net/nMJjS/1/

Just replace the id that I made up with the id of input element you want to change

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM