Adding more than one class html
Yes, it is possible, but you can only declare the class
attribute once per HTML element. Just separate the classes you want to apply by a space.
<a href="#" class="class1 class2">My Text</a>
If you declare the class attribute more than once, all definitions beyond the first will be ignored, so in your code .class2
will not be applied to your link.
How to apply two CSS classes to a single element
1) Use multiple classes inside the class attribute, separated by whitespace (ref):
<a class="c1 c2">aa</a>
2) To target elements that contain all of the specified classes, use this CSS selector (no space) (ref):
.c1.c2 {
}
How to add multiple classes for ul element
In HTML, classes are separated by space. So,
<ul class="sub-menu insert">
Can a div have multiple classes (Twitter Bootstrap)
Sure, a div can have as many classes as you want (this is both regarding to bootstrap and HTML in general):
<div class="active dropdown-toggle"></div>
Just separate the classes by space.
Also: Keep in mind some bootstrap classes are supposed to be used for the same stuff but in different cases (for example alignment classes, you might want something aligned left, right or center, but it has to be only one of them) and you shouldn't use them together, or you'd get an unexpected result, basically what will happen is that the class with the highest specificity will be the one applied (or if they have the same then it'll be the one that's defined last on the CSS). So you better avoid doing stuff like this:
<p class="text-center text-left">Some text</p>
How to add multiple classes in Material UI using the classes props?
you can use string interpolation:
<div className={`${this.props.classes.container} ${this.props.classes.spacious}`}>
How to add multiple classes to a ReactJS Component?
I use classnames when there is a fair amount of logic required for deciding the classes to (not) use. An overly simple example:
...
var liClasses = classNames({
'main-class': true,
'activeClass': self.state.focused === index
});
return (<li className={liClasses}>{data.name}</li>);
...
That said, if you don't want to include a dependency then there are better answers below.
Related Topics
Regular Expression to Remove HTML Tags from a String
How to Include an HTML Page into Another HTML Page Without Frame/Iframe
Why Is Vertical-Align: Middle Not Working on My Span or Div
Css: Control Space Between Bullet and ≪Li≫
Why Is 'Position: Sticky' Not Working With Core Ui'S Bootstrap Css
Background: Fixed No Repeat Not Working on Mobile
Nesting Optgroups in a Dropdownlist/Select
Should I Specify Height and Width Attributes For My Imgs in Html
Preventing Double Borders in CSS Grid
:Last-Child Not Working as Expected
Are You Allowed to Nest a Link Inside of a Link
Flexbox Fill Available Space Vertically
Properly Sizing and Aligning the Flex Item(S) on the Last Row
Ie9 Float With Overflow:Hidden and Table Width 100% Not Displaying Properly
Transparent Half Circle Cut Out of a Div
How to Set Input Type Date'S Default Value to Today