Order summary card challenge on Frontend Mentor HTML, CSS, Guide @rayen-code


This is a solution to the [Order summary card challenge on Frontend Mentor]. Frontend Mentor challenges help you improve your coding skills by building realistic projects.




Step 1: HTML Markup:

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

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">

  <title>Frontend Mentor | Order summary card</title>

  <link rel="stylesheet" href="css/style.css">
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@500;700;900&display=swap');
  </style>
</head>

<body>

  <main>
    <section class="card">
      <div class="image">
        <img src="images/illustration-hero.svg" alt="">
      </div>

      <div class="details">
        <h1 class="header">
          Order Summary
        </h1>

        <p class="disc">
          You can now listen to millions of songs, audiobooks, and podcasts on any
          device anywhere you like!
        </p>

        <div class="price">
          <img src="images/icon-music.svg" alt="">
          <div>
            <h3>Annual Plan</h3>
            <span>$59.99/year</span>
          </div>
          <div class="change">
            Change
          </div>
        </div>

        <button class="btn">
          Proceed to Payment
        </button>

        <div class="cancel">
          Cancel Order
        </div>



      </div>
    </section>
  </main>


</body>

</html>           

Step 2: Styling with CSS:

Create a separate CSS file (style.css)
/*-------------------- CSS --------------------*/
*{
    font-family: 'Red Hat Display', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    min-height: 100vh;
    background: hsl(225, 100%, 94%);
}

main{
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url(/images/pattern-background-desktop.svg) no-repeat;
}
.card{
    width: 450px;
    min-height: 696px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
}

.image{
    width: 100%;

}
.image img{
    width: 100%;
    object-fit: cover;
}

.details{
    width: 100%;
    height: 440px;
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: space-around;
    text-align: center
    ;
    margin-top: 10px;
    padding: 0 40px;
}

.header{
    font-weight: 900;
    color: hsl(223, 47%, 23%);
}

.disc{
width: 350px;
font-size: 16px;
font-weight: 500;
color: hsl(224, 23%, 55%);
}

.price{
    width: 100%;
    height: 98px;
    background: hsl(225, 100%, 98%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 25px;
    position: relative;
}

.price img{
    margin-right: 22px;
}

.price h3{
    font-size: 16px;
    color: hsl(223, 47%, 23%);
    font-weight: 700;

}

.price span{
    font-size: 16px;
    color: hsl(224, 23%, 55%);
}

.price .change{
    position: absolute;
    right: 25px;
    color: hsl(245, 75%, 52%);
    font-weight: 900;
    text-decoration: underline;
    font-size: 14px;
    cursor: pointer;
}
.price .change:active{
    color: hsl(245, 75%, 52%, 0.5);
    text-decoration: none;
}

.btn{
    width: 100%;
    height: 50px;
    border-radius: 8px;
    color: #fff;
    background: hsl(245, 75%, 52%);
    font-weight: 700;
    border: none;
    font-size: 14px;
    box-shadow: 0px 30px 20px hsl(245, 75%, 52%, 0.14);
    cursor: pointer;
}
.btn:active{
    background: hsl(245, 75%, 52%, 0.5);
}

.cancel{
    color: hsl(224, 23%, 55%);
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}
.cancel:active{
color: hsl(223, 47%, 23%);
}

@media (max-width: 375px) {
    main{
        background: url(/images/pattern-background-mobile.svg);
    }

    .card{
        width: 327px;
        min-height: 565px;
    }
    .details{
        margin-top: 0;
        padding: 0 20px;
    }
    .details .disc{
        width: 270px;
    }
    .price{
        height: 90px;
        padding: 15px;
    }

    .change{
        right: 0;
    }

}

0 Comments