Half Diamond By HTML & CSS

 

Half Diamond Hover Effect

If you are searching for How to make Half Diamond by HTML & CSS? then it might be what you are looking for... 

Ingredients :

  • HTML 
  • CSS

Main Focus Point :

  • grid 
  • grid-template-areas  
  • place-items   
  • transform

HTML

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

<head>
    <meta charset="UTF-8">
    <title>Half Diamond</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>

    <div class="container">

        <!-- .box#box-$*6>p.text{$} -->

        <div class="box" id="box-1">
            <p class="text">1</p>
        </div>
        <div class="box" id="box-2">
            <p class="text">2</p>
        </div>
        <div class="box" id="box-3">
            <p class="text">3</p>
        </div>
        <div class="box" id="box-4">
            <p class="text">4</p>
        </div>
        <div class="box" id="box-5">
            <p class="text">5</p>
        </div>
        <div class="box" id="box-6">
            <p class="text">6</p>
        </div>
        
    </div>

</body>

</html>

CSS

* {
    padding   : 0;
    margin    : 0;
    box-sizing: border-box;
}

.container {
    margin: 100px auto;
    width : 350px;

    display              : grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows   : repeat(3, 100px);
    grid-template-areas  :
        "one . ."
        "four two ."
        "six five three";
    gap: 5px;

    /* Rotated Main Container */
    transform: rotate(-45deg);
}

.box {
    background   : tomato;
    border-radius: 5px;
    font         : bold 35px 'Segoe UI';
    display      : grid;
    place-items  : center;
    cursor       : pointer;
    transition   : .3s ease-in-out;
}

.box:hover {
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.7);
}

.text {
    /* Rotated Inner Text */
    transform: rotate(45deg);
}

#box-2 {
    grid-area: two;
}

#box-3 {
    grid-area: three;
}

#box-4 {
    grid-area: four;
}

#box-5 {
    grid-area: five;
}

#box-6 {
    grid-area: six;
}

Comments

Popular posts from this blog

Stack

Get Your Geo Location

React | State Toggling