Home > OS >  I am facing a bit problem in the alignment of my contents in the middle and bottom content
I am facing a bit problem in the alignment of my contents in the middle and bottom content

Time:09-27

This is the image of the website

I am having a bit problem aligning the content in the container to match all the other items in the container, and what else should I do to optimise my css code , I am a beginner to CSS and I was just practicing this project from frontendmentor , I'll be grateful if you could help me with this

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!-- displays site properly based on user's device -->

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

    <title>Frontend Mentor | Profile card component</title>
  </head>
  <body>
    <div >
      <div ><img src="images/bg-pattern-card.svg" /></div>
      <div >
        <img src="images/image-victor.jpg" alt="" />
        <h3 >
          Victor Crest<span> </span><span >26</span>
        </h3>
        <p >London</p>
      </div>
      <hr />
      <div >
        <ul >
          <li>80K</li>
          <li>803K</li>
          <li>1.4K</li>
        </ul>
        <ul >
          <li>Followers</li>
          <li>Likes</li>
          <li>Photos</li>
        </ul>
      </div>
    </div>
  </body>
</html>

CSS

@import url(https://fonts.google.com/specimen/Kumbh Sans);
:root{

--Dark-cyan: hsl(185, 75%, 39%);
--Very-dark-desaturated-blue: hsl(229, 23%, 23%);
--Dark-grayish-blue: hsl(227, 10%, 46%);
}

*{
    margin:0;
    padding:0;
    box-sizing: border-box;
}
body{
    background:url(images/bg-pattern-top.svg),url(images/bg-pattern-bottom.svg) ;
    background-color: var(--Dark-cyan);
    background-repeat: no-repeat;
    background-position: -90% -500px,175% 400px;
    font-family: "Kumbh Sans",sans-serif;
    color:var(--Dark-grayish-blue);
    font-size:18px;

}
.container{
    background-color: #fff;
    height:45%;
    width:30%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin:10rem auto;
    border-radius: 12px;
    position: relative;
}
.top-content,.bottom-content{
    width: 100%;
}
.top-content{
    width: 100%;
    height:33%;
}
.top-content img{
    width: 100%;

}
.middle-content img{
    border-radius: 50%;
    border:6px solid #fff;
    position: absolute;
    top:30%;
    left:37%;

}
h3{
    margin-top:70%;
    color:#000;
}
.age{
    color:var(--Dark-grayish-blue);
    padding-left: 0.5em;
}
p.location{
    position:relative;
    left:35px;
    padding:1.25rem 0;

}
ul{
    display: flex;
    justify-content: space-around;
    padding-top:1rem;
}
ul.numbers li{
    font-weight:700;
    color: #000;
}
ul.description-numbers li{
    padding-bottom:1rem;
    font-size: 15px;
    letter-spacing: 0.1em;
}

ul li{
    list-style: none;
}
hr{
    height:1px;
    opacity: 0.5;
    width: 100%;
    background-color: var(--Dark-grayish-blue);
}

CodePudding user response:

TRY THIS OUT AND LET ME KNOW

Add a center class to your top container.

<div >

Add this CSS code to your stylesheet

.center {
 margin: auto;
 width: 50%;
}

CodePudding user response:

I would change the html a little bit for that.

<ul >
    <li>
        <span>80K</span>
        <span>Followers</span>
    </li>
    <li>
        <span>803K</span>
        <span>Likes</span>
    </li>
    <li>
        <span>1.4K</span>>
        <span>Photos</span>
    </li>
</ul>

And the css

.bottom-content {
  display: flex;
  justify-content: space-around;
}

.bottom-content > li {
  display: flex;
  flex-direction: column;
  align-items: center;
}

  • Related