How to Create: Card
- Previous page Contact chip
- Next page Flip card
Learn how to use CSS to create a 'card'.

Bill Gates
Architect & Engineer

Jane Doe
Interior Designer
How to Create a Card
Step 1 - Add HTML:
<div class="card"> <img src="img_avatar.png" alt="Avatar" style="width:100%"> <div class="container"> <h4><b>Bill Gates</b></h4> <p>Architect & Engineer</p> </div> </div>
Step 2 - Add CSS:
.card { /* Add shadow to create the 'card' effect */ box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); transition: 0.3s; } /* Add a deeper shadow when the mouse hovers */ .card:hover { box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); } /* Add some inner padding to the card container */ .container { padding: 2px 16px; }
With rounded corners:
Example
.card { box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); transition: 0.3s; border-radius: 5px; /* 5px rounded corners */ } /* Add rounded corners to the top left and top right of the image */ img { border-radius: 5px 5px 0 0; }
Related pages
Tutorial:CSS shadow effect
- Previous page Contact chip
- Next page Flip card