How to Create a card in HTML with CSS.

In this tutorial, we will see how to create a Card in HTML and will give it some style effects using CSS. In this tutorial we will create a Artist Card. You can edit this card on your own if you want card for different things like your profile card etc.



Introduction:

In this, we will be creating 3 cards and will use display:flex; property to align them horizontally. Also, we will use Font Awesome icon pack for Social media icons and give them :hover style.
Let's start with HTML code firstly.

HTML

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
    <link rel="stylesheet" href="Cards.css" />
</head>

<body>
    <!--Card container starts here-->
<div class="card-container">

    <div class="card1-container" style="display: flexbox">

    <div class="artist-image">
    <img height="400" src="Media/Artist3.jpg" />
    </div>

    <div class="artist-name">
    <p>Ed Sheeran</p>
    </div>
    <br />

    <div class="artist-description">
    <p style="text-align: center">Singer, Writer, Musician.</p>
    <br />
    </div>
    
    <div class="artist-social-media">
    <ul class="social-media-list" style="list-style: none; display: inline-flex">
    <li class="instagram">
    <a href="#insta" title="Instagram" style="color: black">
    <i class="fa fa-instagram"></i>
    </a>
    </li>
    <li class="facebook">
    <a href="#fb" title="Facebook" style="color: black">
    <i class="fa fa-facebook"></i></a>
    </li>
    <li class="twitter">
    <a href="#twitter" title="Twitter" style="color: black">
    <i class="fa fa-twitter"></i>
    </a>
    </li>
    </ul>
    </div>

    <div class="artist-button">
    <input type="Button" value="See Full Profile" />
    </div>
    </div>

    </div>
    <!--Card container ends here-->
    </body>

</html>

ADVERTISEMENT


Now we have created our HTML Structure for cards, Let's apply some CSS Properties to give this card a good look.

CSS

* {
  margin0;
  padding0;
  font-familyArialHelveticasans-serif;
}
.card-container {
  widthmax-content;
  marginauto;
  justify-contentspace-between;
  displayflex;
}
.card1-container {
  margin20px;
  width300px;
  border1px solid black;
  text-aligncenter;
  heightmax-content;
  box-shadow0 5px 10px rgba(000.2);
}
.card1-container img {
  width100%;
}
.artist-image {
  width300px;
}

.artist-description {
  padding10px;
  text-alignjustify;
  line-height1.5;
}
.artist-name {
  color#000;
  text-transformuppercase;
  letter-spacing2px;
  font-weight600;
}

.social-media-list > li {
  text-aligncenter;
  font-size21px;
  padding-right20px;
}
.artist-button input[type="button"] {
  background-colortransparent;
  bordernone;
  color#679bcf;
  cursorpointer;
  margin-top10px;
  margin-bottom10px;
  font-weightbold;
  font-size14px;
  padding15px;
  letter-spacing2px;
}
.artist-button input[type="button"]:hover {
  background#444d55;
  letter-spacing1px;
  -webkit-box-shadow0px 5px 40px -10px rgba(0000.57);
  -moz-box-shadow0px 5px 40px -10px rgba(0000.57);
  box-shadow5px 40px -10px rgba(0000.57);
  transitionall 0.4s ease 0s;
}
.fa-instagram:hover {
    color#dd2a7b;
    transition0.2s ease-in;
}
  .fa-facebook:hover {
    colorrgb(3838204);
    transition0.2s ease-in;
}
  .fa-twitter:hover {
    color#13a3b5;
    transition0.2s ease-in;
}

If you have any question or query drop a comment below in comment-box and we'll answer your question ASAP

Output:

ED Sheeran image credits: Wikipedia

Live Example:

Credits:Codepen

In this codepen example, we have used 2 cards in which display:flex; property is used.

See the Pen Cards in HTML using CSS by Abhishek Raj (@_abhishek_raj_) on CodePen.

Previous Post Next Post

Contact Form