Wednesday, 31 January 2024

How to center Align Image by using HTML and CSS

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>


    <style>

        body{

            display: flex;

            align-items: center;

            justify-content: center;

            height: 100vh;

            margin: 0;

        }

        .circular-image{

            width: 150px;

            height: 150px;

            border-radius: 50%;

            overflow: hidden;

        }

        .circular-image img{

            width: 100%;

            height: 100%;

            object-fit: cover;

        }


    </style>

</head>

<body>

    <div class="circular-image">

        <img src="./image.jpg" alt="image is not shown">

    </div>

</body>

</html>