Hello everyone,
I'm curious if there is a way to create a custom CSS class that incorporates existing Bootstrap classes?
For instance, take a look at the following snippet of HTML:
<div class="text-primary center-block">Here is some text</div>
By using these Bootstrap classes, the text will automatically be styled as blue, centered, and displayed as a block. However, it can be cumbersome to remember all of these classes. Is there a way for me to simply define my own class like this:
<div class="my_class">Here is some text</div>
And then somehow in a CSS file apply those Bootstrap properties?
The only workaround I've come up with involves using JQuery, as shown below:
$(document).ready(
function() {
$(".my_class").each(function() {
$(this).addClass("text-primary center-block");
});
}
);
But I'm wondering if there might be a more efficient solution out there. Any thoughts?