Make an Image Hover Card effect in HTML and CSS


In This Tutorial I Will Show you how to make an Image Hover card effect using only HTML and CSS. it's a pretty effect that you can implement to your blog 


HTML CODE : 

<!DOCTYPE HTML>

<html>

<head>

    <title>POST CARD</title>

    <link rel="stylesheet" href="style/main.css">

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css"

        integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">

    <script type="text/javascript" src="jquery-3.3.1-min.js"></script>

</head>

<body>

    <div id="test" class="card">

        <div class="cover">

            <img src="img_res/cover.jpg">

            <div class="black">

                <img src="img_res/profile.png">

                <div class="text_info">

                    <p>Doctor code</p>

                    <p>my work space , this is an image </p>

                </div>

            </div>

        </div>

        <div class="text">

            <div class="desc">

               <h1>Description :</h1>

                <p>

                    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce fermentum pellentesque scelerisque.

                    Proin iaculis ante velit, sit amet mollis lacus blandit non. Aenean sed dolor sed nibh feugiat

                    dapibus a id mauris. Proin in neque eget metus dapibus tempor ac eu leo. Nunc vestibulum ut felis ac

                    blandit. Pellentesque faucibus quam quis orci tincidunt tempor. In hac habitasse platea dictumst.

                    Aenean arcu sem, feugiat sed nisl in, tempus rutrum mi.

                </p>

            </div>

            <div id="test" class="info">

                <div class="col">

                    <h1>220K</h1>

                   <i class="far fa-heart"></i>

                </div>

                <div class="col">

                    <h1>5.4M</h1>

                    <i class="far fa-eye"></i>

                </div>

                <div class="col">

                    <h1>32K</h1>

                    <i class="fas fa-share-alt"></i>

                </div>

            </div>

        </div>

    </div>

</body>

</html>

CSS PART :


@import url('https://fonts.googleapis.com/css?family=Montserrat|Open+Sans:300,400|Roboto');



* {
    margin0;
    padding0;
    outline0;
}
body {
    background#fff;
}
.card {
    positionabsolute;
    left50%;
    top50%;
    transformtranslate(-50%-50%);
    width550px;
    height500px;
    background-color#fafafa;
    color#212121;
    border-radius15px;
    overflowhidden;
    cursorpointer;
    box-shadow0px 1px 15px rgba(353535.8);
}
.card img {
    width100%;
}
.black {
    z-index2;
    background-colorrgba(353535.6);
    positionabsolute;
    top0;
    left0;
    right0;
    bottom0;
    padding15px;
    color#fafafa;
    transition: opacity .4s ease-in-out;
    opacity0;
    font-family'Open Sans'sans-serif;
}
.black img {
    width64px;
    height64px;
    border-radius100%;
    border2px solid #fafafa;
    floatleft;
}
.black .text_info {
    floatleft;
    margin-left15px;
    margin-top15px;
}
.text {
    positionabsolute;
    bottom0;
    z-index3;
    padding15px 15px 0 15px;
    heightauto;
    background-color#fafafa;
}
.desc {
    widthcalc(100%);
    background-color#fafafa;
    overflowhidden;
    margin-bottom-300px;
    opacity0;
    transitionall .4s ease-in-out;
}
.desc h1 {
    margin-bottom15px;
    font-family'Open Sans'sans-serif;
}
.desc p {
    font-size.9rem;
    line-height1.8rem;
    font-family'Montserrat'sans-serif;
}
.info {
    heightcalc(100% + 30px);
    widthcalc(100% + 30px);
    background-color#fafafa;
    text-aligncenter;
    displayflex;
    flex-directionrow;
    positionrelative;
    left50%;
    padding15px 0;
    transformtranslateX(-50%);
}
.info h1 {
    font-family'Open Sans'sans-serif;
    font-weight300;
}
.info .col {
    width33%;
}
.info .col i {
    font-size1.8rem;
}
.card:hover .desc {
    margin-bottom15px;
    opacity1;
}
.card:hover .black {
    opacity1;
}

after pasting code please make sure that you added the images with the same name. and make sure that you copied all the code.

now let's explain how this works.
as I said it's composed of 3 layers I will not explain all of them I will only explain the animation part
- for the second layer, I just made a black background effect and I applied an opacity to it ( opacity:0.3;) to make that amazing filter effect and I added the profile picture and the information and I used flex-box to make that layout I made the opacity of the fill layer two 0 and when it the mouse hover on it it becomes 1 and I added a transition effect.
for the second layer, I used margin-down to hide the description and when it hovers the margin return to 0 to make that amazing translation effect. and that's it.

if you want to learn more details about this tutorial I invite you to watch my youtube video to see all the steps 





Make an Image Hover Card effect in HTML and CSS Make an Image Hover Card effect in HTML and CSS Reviewed by Medics on March 05, 2019 Rating: 5

2 comments:

  1. how can I add a card??

    ReplyDelete
    Replies
    1. you can create a card using HTML and CSS like what i have made

      Delete

-->
Powered by Blogger.