skip to Main Content

Here is the image, stack overflow does not allow me to directly post image here...I’m building a portfolio website and want the "About Me" section to appear below the introductory title with a clear separation. My HTML is structured like this:

Please tell me what is wrong since im not able to create a about me section , contact etc like how a portfolio website should be.

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at bottom, #0d1d31 0%, #0c0d13 100%);
  overflow: hidden;
}
a {
  color: inherit;
  text-decoration: inherit;
}

::selection {
  background-color: #f7ca18;
  color: #1b1b1b;
}

nav {
  width: 100%;
  background-color: #0b0b0b;
  position: fixed;
  top: 0;
  left: 0;
  height: 100px;
  overflow: hidden;
  font-family: 'Open Sans', sans-serif;
  z-index: 100;
}

nav ul {
  position: absolute;
  top: 0;
  left: 0;
  list-style-type: none;
  padding: 0;
  margin: 0;
  width: 100vw;
}

nav li {
  margin: 0;
  float: left;
  display: inline-block;
  height: 98px;
  margin-bottom: 2px;
  line-height: 100px;
  width: 20vw;
  text-align: center;
  color: #555;
  transition: background-color 0.5s 0.2s ease, color 0.3s ease;
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 800;
  transform: translateY(100%);
}

nav li.active {
  background-color: #151515;
  color: #efefef;
}

nav li.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: #f7ca18;
}

nav li:nth-child(1) {
  animation: pop 0.5s 0.15s 1 forwards;
}

nav li:nth-child(2) {
  animation: pop 0.5s 0.3s 1 forwards;
}

nav li:nth-child(3) {
  animation: pop 0.5s 0.45s 1 forwards;
}

nav li:nth-child(4) {
  animation: pop 0.5s 0.6s 1 forwards;
}

nav li:nth-child(5) {
  animation: pop 0.5s 0.75s 1 forwards;
}

nav li:nth-child(6) {
  animation: pop 0.5s 0.9s 1 forwards;
}

nav li:nth-child(7) {
  animation: pop 0.5s 1.05s 1 forwards;
}

nav li:hover {
  color: #ececec;
}

nav li:active {
  background-color: #222;
}

nav li:nth-child(1):hover ~ .slide {
  left: 0;
}

nav li:nth-child(2):hover ~ .slide {
  left: 20vw;
}

nav li:nth-child(3):hover ~ .slide {
  left: 40vw;
}

nav li:nth-child(4):hover ~ .slide {
  left: 60vw;
}

nav li:nth-child(5):hover ~ .slide {
  left: 80vw;
}

nav li:nth-child(6):hover ~ .slide {
  left: 100vw;
}

nav li:nth-child(7):hover ~ .slide {
  left: 120vw;
}

nav li.slide {
  position: absolute;
  left: -20vw;
  top: 0;
  background-color: #fff;
  z-index: -1;
  height: 2px;
  margin-top: 98px;
  transition: left 0.3s ease;
  transform: translateY(0);
}

section {
  display: flex;
  font-family: 'Open Sans', sans-serif;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

section .title {
  max-width: 80%;
  width: 100%;
  margin-bottom: 40px; 
}

section .title span {
  display: inline-block;
  font-size: 5vw;
  color: #efefef;
  width: 100%;
  text-transform: uppercase;
  transform: translateX(-100%);
  animation: byBottom 1s ease both;
  font-weight: 600;
  letter-spacing: 0.25vw;
}

section .title span:last-child {
  font-size: 1rem;
  animation: byBottom 1s 0.25s ease both;
}

section .title span a {
  position: relative;
  display: inline-block;
  margin-left: 0.5rem;
  text-decoration: none;
  color: #f7ca18;
}

section .title span a::after {
  content: "";
  height: 2px;
  background-color: #f7ca18;
  position: absolute;
  bottom: -10px;
  left: 0;
  width: 0;
  animation: linkAfter 0.5s 1s ease both;
}
<nav>
  <ul>
    <li><a href="XXX">Home</a></li>
    <li>About me</li>
    <li>My Projects</li>
    <li>Social Media</li>
    <li>Contact me</li>
    <li class="slide"></li>
  </ul>
</nav>
<section>
  <div class="title">
    <span>Astroisback</span><span>CSE Student at<a target="_black" href="">XXX</a></span>
  </div>
  </div>
</section>
<section id="about-me">
  <h2>About Me</h2>
  <p>Welcome to my portfolio website!</p>
</section>

I’m trying to put about me section down side, like how it should be in a portfolio website but as you can see whatever section i create it just does not work that is causing me issue for creating differnt secton for contact me, home , projects, etc.
Yoou can see the image for refernece.

2

Answers


  1. You’re using flex which is causing it to move right side.

    You can either use flex-direction: column; or remove flex from section

    If you still want to use flex, refer to code below:

    section{
       display:flex;
       flex-direction: column;
    }
    <section>
    <h1>Hello World</h1>
    <p>About me</p>
    </section>
    Login or Signup to reply.
  2. As another friend mentioned, if you wanna do this with Flex you should take a look at the document. I changed your code a little bit, hope it helps.

    body {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 100vh;
      overflow: hidden;
    }
    
    nav {
      display: flex;
      flex-direction: column;
      flex: 1;
      background-color: #0b0b0b;
      font-family: 'Open Sans', sans-serif;
      max-height: 90px;
    }
    
    nav ul {
      display: flex;
      flex-direction: row;
      list-style-type: none;
      padding: 0;
      margin: 0;
      width: 100vw;
    }
    
    nav li {
      flex:1;
      margin: 0;
      text-align: center;
      color: #555;
      transition: background-color 0.5s 0.2s ease, color 0.3s ease;
      cursor: pointer;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 1px;
      font-weight: 800;
      transform: translateY(100%);
    }
    
    .sectionsOrder{
      display: flex;
      flex-direction: row;
      align-items: center;
      flex: auto;
    }
    
    .section1 {
      display: flex;
      flex-direction: column;
      flex:2;
      font-family: 'Open Sans', sans-serif;
      align-items: center;
      padding: 20px;
    }
    
    .section2 {
      display: flex;
      flex-direction: column;
      flex:1;
      font-family: 'Open Sans', sans-serif;
      align-items: center;
      padding: 20px;
    }
    
    section .title {
      max-width: 80%;
      width: 100%;
      margin-bottom: 40px; 
    }
    
    section .title span {
      font-size: 5vw;
      color: #efefef;
      width: 100%;
      text-transform: uppercase;
      transform: translateX(-100%);
      animation: byBottom 1s ease both;
      font-weight: 600;
      letter-spacing: 0.25vw;
    }
    
    section .title span:last-child {
      font-size: 1rem;
      animation: byBottom 1s 0.25s ease both;
    }
    
    section .title span a {
      margin-left: 0.5rem;
      text-decoration: none;
      color: #f7ca18;
    }
    
    section .title span a::after {
      content: "";
      height: 2px;
      background-color: #f7ca18;
      position: absolute;
      bottom: -10px;
      left: 0;
      width: 0;
      animation: linkAfter 0.5s 1s ease both;
    }
    <nav>
      <ul>
        <li><a href="XXX">Home</a></li>
        <li>About me</li>
        <li>My Projects</li>
        <li>Social Media</li>
        <li>Contact me</li>
        <li class="slide"></li>
      </ul>
    </nav>
    <div class="sectionsOrder">
      <section class="section1">
        <div class="title">
          <span>Astroisback</span><span>CSE Student at<a target="_black" href="">XXX</a></span>
        </div>
      </section class="section1">
      <section id="about-me">
        <h2>About Me</h2>
        <p>Welcome to my portfolio website!</p>
      </section>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search