Card is a frequently used part of some popular CSS frameworks such as bootstrap, materialize, Bulma and others. Cards are used to group elements such as pictures, paragraphs, and more. Card has two forms. vertical and horizontal. in this tutorial we will make a card that is vertical.
in the previous tutorial, I have created a container to set the width of our web content. please follow my previous tutorial Create Our Own CSS Frameworks part-3 so you will not be confused.
Element Card:
<div class="columns">
<div class="column">
<img src="assets/example-img.png">
<div class="title">Title Cards</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
Title Cards
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry'
s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
</div>
<div class="column">
<img src="assets/example-img.png">
<div class="title">Title Cards</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
</div>
</div>
Result:
Open a command prompt on your project and run gulp. Open http://localhost:8080/ in your browser to see the results.
I will create a class that will be responsible for styling the card. the class name is class="cards".
Example Class .cards:
.cards
background: white
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04)
border-radius: 3px
img
width: 100%
.title
font-size: 20px
font-weight: bold
margin: 10px 0px
Use the ".cards":
<div class="column cards">
<img src="assets/example-img.png">
<div class="title">Title Cards</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
</div>
After we create the class .cards, we can easily use it like this < div class = "column cards" > </ div >,
we still use the class column because we need it to create a column effect on our cards. Now we can use it by adding class "cards". You can try replacing the CSS with the style you want.
Result: