Home >Web Front-end >CSS Tutorial >How Can I Override Twitter Bootstrap\'s Styles?
Overriding Styling in Twitter Bootstrap
In this instance, you wish to modify the float property of the sidebar class in Twitter Bootstrap. As a newer web developer, this task may seem daunting. However, here are a few simple solutions:
Method 1: Reassign the float Property
After you have included Bootstrap's stylesheet (bootstrap.css), add your custom stylesheet (site-specific.css). This will allow you to override existing rules by redefining them. For example:
.sidebar { float: right; }
Note: The above will work for any CSS style you wish to overwrite.
Method 2: Use the !important Rule (Less Recommended)
If you want to be more specific about your overriding style, you can append the !important rule to the CSS property. This will ensure that your custom style takes precedence over Bootstrap's style. However, it is generally recommended to avoid using !important excessively.
.sidebar { float: right !important; }
The above is the detailed content of How Can I Override Twitter Bootstrap\'s Styles?. For more information, please follow other related articles on the PHP Chinese website!