Home > Net >  webpage not showing full content when window is minimised
webpage not showing full content when window is minimised

Time:10-16

I coded a webpage recently, I was able to get the result. But I am now having a issue with css viewport. My webpage only shows the left part of my content when minimizing the windows instead of showing the full content, please help guys. I currently hosted the page in github. Webpage github link: https://jtmuthu.github.io/card1/

CodePudding user response:

Youre using fixed values for positioning, that wont work with resizing the page.

You need to work with percentages, responsive positioning and other fluid values.

Ive created a snipped from your github page and changed the neccessary styles.

body {
  background-color: hsl(225, 100%, 94%);
  margin: 0;
  height: auto;
  width: auto;
  font-family: 'Red Hat Display', sans-serif;
}

.bg-img {
  width: 100%;
  height: auto;
}

.card {
  background-color: hsl(225, 100%, 98%);
  color: black;
  position: relative;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  max-width: 450px;
  margin: 50px auto;
}

.music {
  background-color: rgba(232, 232, 232, 1);
  border-radius: 10px;
  color: black;
  height: 90px;
  width: calc(100% - 120px);
  margin: 0 60px;
}

.cardimg {
  border-radius: 20px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

h1 {
  text-align: center;
  padding-top: 40px;
}

.p1 {
  text-align: center;
  width: 70%;
  line-height: 2;
  margin-left: 65px;
}

.msic {
  position: relative;
  left: 20px;
  top: 20px;
}

.p2 {
  float: right;
  padding-right: 140px;
  line-height: 2;
}

a {
  position: relative;
  left: 200px;
  bottom: 14px;
  text-decoration: underline;
}

a:hover {
  text-decoration: none;
  color: blue;
}

.p3 {
  color: hsl(224, 23%, 55%);
  padding-left: 180px;
  padding-top: 30px;
}

.p3:hover {
  color: black;
  font-weight: bolder;
}

.btn {
  position: relative;
  left: 40px;
  top: 20px;
  color: white;
  background-color: rgb(56, 41, 224);
  height: 50px;
  width: 360px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
}

.btn:hover {
  background-color: rgba(56, 41, 224, 0.8);
}
<html lang="en" dir="ltr">

<head>
  <meta charset="utf-8">
  <link rel="icon" href="https://jtmuthu.github.io/card1/images/favicon-32x32.png">
  <title>Summary Card</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://fonts.googleapis.com/css2?family=Red Hat Display:wght@300&amp;display=swap" rel="stylesheet">
  <style></style>
</head>

<body>
  <div class="bg">
    <img class="bg-img" src="https://jtmuthu.github.io/card1/images/pattern-background-desktop.svg" alt="bg">
  </div>

  <div class="card">
    <img class="cardimg" src="https://jtmuthu.github.io/card1/images/illustration-hero.svg" alt="hero">
    <h1>Order Summary</h1>

    <p class="p1">You can now listen to millions of songs, audiobooks and podcasts on any device anywhere you like!</p>
    <div class="music">
      <img class="msic" src="https://jtmuthu.github.io/card1/images/icon-music.svg" alt="msic">
      <p class="p2"><strong>Annual Plan</strong> <br> $59.99/year</p>
      <a href="#">Change</a>

    </div>
    <div class="bottom">
      <button class="btn" type="button" name="button">Proceed to Payment</button>
      <p class="p3">Cancel Order</p>

    </div>
  </div>
</body>

</html>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

It's because you hardcoded the positions. And how big or small the browser window, they stay the same.

My sugestion: use a flexbox. With that, you can keep everything centered without left or bottom values. (Note: if the browser window is smaller than the card there obviously will be cut off a part. For that you can use media queries).

<body>
<div class="flexbox">
  <div class="container">
     // All the content here WITHOUT POSITIONING
  </div>
</div>
</body>

And as css

.flexbox{
    display: flex;
    align-items: center;
    justify-content: center;
  }
.container{
  width: 450px;
  height: 660px;
  }

And a fiddle

CodePudding user response:

  1. probably because you using,

    left: 460px;
    

    instead this try to use <center> tag.

  2. it is advisable to use media query for responsive

  • Related