Home > Software engineering >  How to move list items to the right?
How to move list items to the right?

Time:12-28

I'm working on a portfolio website, and the footer section is not the way I want it to look. I want to move the unordered list items to the right side. I have tried justify-content: right;, justify-content: end;, and right, however, it doesn't work.

.footer {
  grid-area: footer;
  margin-top: 38px;
  margin-left: 10%;
  margin-right: 10%;
  height: 700px;
  margin-bottom: 100px;
}

.footer-text {
  padding: 200px 100px;
  font-family: "Khula", sans-serif;
  font-weight: 600;
  font-size: 80px;
  color: #bbbbbb;
  line-height: 80px;
  letter-spacing: -1px;
  display: inline-block;
}

.footer-contact {
  font-family: "Khula", sans-serif;
  font-weight: 600;
  font-size: 35px;
  color: #222222;
  line-height: 50px;
  letter-spacing: -1px;
  text-decoration: none;
  padding-top: 0px;
  margin-left: 60px;
  margin-right: 60px;
}

.footer-text-color {
  color: #222222;
}

ul {
  list-style-type: none;
  text-decoration: none;
  display: inline-block;
}
<footer >

  <div >Let's <br> <span >Connect</span></div>

  <ul>

    <li><a href=a.html >Email</a></li>
    <li><a href=b.html >LinkedIn</a></li>
    <li><a href=c.html >GitHub</a></li>
  </ul>

</footer>

CodePudding user response:

Give your <ul> a class. I called it center. Then add the following styles as seen in the CSS. Also, remove the margin-left: 60px; on footer-contact I re spaced them with a flex-box on the parent.

.footer {
    grid-area: footer;
    height: 700px;
    margin-bottom: 100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.footer-text {
  padding: 200px 100px;
  font-family: "Khula", sans-serif;
  font-weight: 600;
  font-size: 80px;
  color: #bbbbbb;
  line-height: 80px;
  letter-spacing: -1px;
  display: inline-block;
}

.footer-contact {
  font-family: "Khula", sans-serif;
  font-weight: 600;
  font-size: 35px;
  color: #222222;
  line-height: 50px;
  letter-spacing: -1px;
  text-decoration: none;
  padding-top: 0px;
  margin-right: 0;
}

.footer-text-color {
  color: #222222;
}

ul {
  list-style-type: none;
  text-decoration: none;
  display: inline-block;
}

ul li {
  text-align: right;
}

.center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    position: relative;
    right: 0;
}
<footer >

  <div >Let's <br> <span >Connect</span></div>
  
  <ul >

    <li><a href=a.html >Email</a></li>
    <li><a href=b.html >LinkedIn</a></li>
    <li><a href=c.html >GitHub</a></li>
  </ul>

</footer>

CodePudding user response:

Just replace margin-right: 60px; with margin-right: 0; in footer-contact and also add below CSS.

ul li {
  text-align: right;
}

I also update your code snippet, it'll help you out. Thank You

.footer {
  grid-area: footer;
  margin-top: 38px;
  margin-left: 10%;
  margin-right: 10%;
  height: 700px;
  margin-bottom: 100px;
}

.footer-text {
  padding: 200px 100px;
  font-family: "Khula", sans-serif;
  font-weight: 600;
  font-size: 80px;
  color: #bbbbbb;
  line-height: 80px;
  letter-spacing: -1px;
  display: inline-block;
}

.footer-contact {
  font-family: "Khula", sans-serif;
  font-weight: 600;
  font-size: 35px;
  color: #222222;
  line-height: 50px;
  letter-spacing: -1px;
  text-decoration: none;
  padding-top: 0px;
  margin-left: 60px;
  margin-right: 0;
}

.footer-text-color {
  color: #222222;
}

ul {
  list-style-type: none;
  text-decoration: none;
  display: inline-block;
}

ul li {
  text-align: right;
}
<footer >

  <div >Let's <br> <span >Connect</span></div>

  <ul>

    <li><a href=a.html >Email</a></li>
    <li><a href=b.html >LinkedIn</a></li>
    <li><a href=c.html >GitHub</a></li>
  </ul>

</footer>

  • Related