Materialize CSS Cards
Cards are a convenient means of displaying different types of relevant content. Materialize uses cards for presenting similar objects whose sizes and actions can be changed with the requirement. Here is an example of a basic card.
Materialize provides different types of card according to its requirement, following are the names :
- Image Card: It is used for a standard card with the help of image thumbnail. For this card-image class is added inside the card class.
- FABs in Cards: Within the image card, floating action buttons can be added with different sizes.
- Horizontal Cards: In this, space is divided into two blocks where one side is used for image and the other for information.
- Cards Reveal: This is used for adding extra information which can be accessed by a click. For this to work, card-reveal div is added with span card-title class and to open card reveal, activator class is added to an element inside the card.
- Tabs in Cards: This is used to add different tabs in the card. To add this, cards-tabs class is added in between the header and tab content.
- Card Panel: This is used for a simple card that requires minimum markup with padding and shadow effect.
Here is an example shown that uses all the above cards:
We can also make uniformly sized cards using the materialize CSS classes.
i. small – The “small class” is used to make cards of height up to 300px.
<div class="card small"> <!-- Card Content --> </div>
ii. medium – The “medium class” is used to make cards of height up to 400px.
<div class="card medium"> <!-- Card Content --> </div>
iii. large – “The large class” is used to make cards of height up to 500px.
<div class="card large"> <!-- Card Content --> </div>
- We can also define custom heights to the cards using CSS.
- If we don’t mention any card size or class , then the card gets the height and width default to auto , i.e , the height and width increases with the increase in the content.
Here is a code example showing different cards of different sizes:
We can also make cards of different colors and also add different text colors to the card using different colors from the Materialize CSS color palette.
<div class="card purple darken-3"> <!-- Card Content --> </div>
Full Code example :
- Google Chrome
- Brave Browsers
- Mozilla Firefox
- Microsoft Edge