Why is align-items:center working incorrectly in safari?

578 views Asked by At

my design looks correct in firefox or chrome but wrong in safari. I don't understand why this is so. If I remove the 'align-items:center' it looks correct but why? I don't have a mac device so I can't try fixing it.

If you want to see what the real website looks like, link here:https://earslanyunus-statspreviewcard.netlify.app

And all codes

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Lexend+Deca&display=swap");
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.soft-violet {
  color: hsl(277, 64%, 61%);
}

.lexendDeca {
  font-family: "Lexend Deca", "sans-serif";
  font-weight: 400;
}

p,
a {
  font-size: 15px;
}

html {
  font-size: 62.5%;
}

body {
  background-color: hsl(233, 47%, 7%);
  font-family: "sans-serif", "Inter";
}

main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  flex-direction: column;
}

.card {
  max-width: 120rem;
  background-color: hsl(244, 38%, 16%);
  border-radius: 10px;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr 1fr;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  -webkit-box-align: center;
  -ms-flex-align: center;

  /*problem here*/
  align-items: center;

}

.img-box {
  height: 100%;
  background-color: rgb(170, 92, 219);
  background-image: url("stats-preview-card-component-main/images/image-header-desktop.jpg");
  background-blend-mode: multiply;
  background-size: cover;
}

.card-img {
  width: 100%;
  height: 100%;
  opacity: 0.7;
}

.text-box {
  padding: 7rem 9rem 7rem 7rem;
}

.title {
  font-size: 4rem;
  color: white;
}

.text-desc {
  margin-top: 3rem;
  color: hsla(0, 0%, 100%, 0.75);
  line-height: 1.8;
  font-size: 1.6rem;
}

.stat-box {
  margin-top: 8rem;
  display: -ms-grid;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.stats-num {
  font-weight: 700;
  color: white;
  font-size: 2.5rem;
}

.stats-text {
  font-size: 1.4rem;
  color: hsla(0, 0%, 100%, 0.6);
  margin-top: 0.2rem;
}

.footer,
.footer a {
  font-size: 1.3rem;
  color: white;
}

.footer a:link,
.footer a:visited {
  color: white;
}

.footer a:hover,
.footer a:active {
  color: hsl(277, 64%, 61%);
  text-decoration: none;
}

.footer-box {
  margin-top: 3rem;
}

@media all and (max-width: 59.6em) {
  .text-box {
    padding: 4rem 5rem 4rem 4rem;
  }
}

@media all and (max-width: 50.7em) {
  html {
    font-size: 50%;
  }
  .card {
    -ms-grid-columns: 1fr;
    grid-template-columns: 1fr;
    -ms-grid-rows: 1fr 2fr;
    grid-template-rows: 1fr 2fr;
  }
  .img-box {
    grid-row-start: 1;
  }
  .text-box {
    padding: 3rem 5rem 3rem 3rem;
  }
  .stat-box {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, 1fr);
    justify-items: center;
    row-gap: 2rem;
  }
  p {
    text-align: center;
  }
  h1 {
    text-align: center;
  }
}
<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta charset="utf-8">
  <link rel="stylesheet" href="style.css">
  <link rel="shortcut icon" href="stats-preview-card-component-main/images/favicon-32x32.png" type="image/x-icon">
  <title>Stats Preview Card</title>
</head>

<body>
  <main>
    <div class="card">
      <div class="text-box">
        <h1 class="title">Get <span class="soft-violet">insights</span> that help your business grow.</h1>
        <p class="text-desc lexendDeca">Discover the benefits of data analytics and make better decisions regarding revenue, customer experience, and overall efficiency.</p>
        <div class="stat-box">
          <div class="">
            <p class="stats-num">10k+</p>
            <p class="stats-text lexendDeca">COMPANIES</p>
          </div>
          <div class="">
            <p class="stats-num">314</p>
            <p class="stats-text lexendDeca">TEMPLATES</p>
          </div>
          <div class="">
            <p class="stats-num">12M+</p>
            <p class="stats-text lexendDeca">QUERIES</p>
          </div>
        </div>
      </div>
      <div class="img-box">
        <!-- <img class="card-img" src="stats-preview-card-component-main/images/image-header-desktop.jpg" alt=""> -->
      </div>
    </div>
    <div class="footer-box">
      <p class="footer text-align-center">Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a></p>
      <p class="footer  text-align-center">Coded by <a href="https://github.com/earslanyunus" target="_blank">Yunus Emre Arslan</a></p>
    </div>
  </main>
</body>

</html>

1

There are 1 answers

0
Ben Souchet On

To get the consistency between Chrome / Firefox and Safari :

  • Remove align-items: center; on the .card element
  • Remove height:100%; on .img-box element