Home > Mobile >  Hours are slightly to the right
Hours are slightly to the right

Time:02-12

I cannot get the hours ul to line up with the hours h2. It is just slightly to the right and I want it to line up directly underneath.

I am not sure what else I could try. I am new to html and css.

body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 20px;
}

#hero h2 {
  display: block;
  width: fit-content;
  font-size: 2rem;
  position: relative;
}

#hero ul li {
  display: block;
  width: fit-content;
  font-size: 1.5rem;
  position: relative;
}

.hours ul {
  margin: 0;
  padding: 0;
}

.hours li {
  list-style: none;
}

.hours li {
  text-decoration: none;
  color: black;
  padding: .5rem;
  display: block;
}
<section id="hero">
  <div >
    <div >
      <h2>Hours</h2>
      <div >
        <ul>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
        </ul>
      </div>
    </div>
</section>

CodePudding user response:

Your .hours li have padding: .5rem that's why.
You might set padding:.5rem 0 to align better.

body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 20px;
}

#hero h2 {
  display: block;
  width: fit-content;
  font-size: 2rem;
  position: relative;
}

#hero ul li {
  display: block;
  width: fit-content;
  font-size: 1.5rem;
  position: relative;
}

.hours ul {
  margin: 0;
  padding: 0;
}

.hours li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hours li {
  text-decoration: none;
  color: black;
  padding: .5rem 0;
  display: block;
}
<section id="hero">
  <div >
    <div >
      <h2>Hours</h2>
      <div >
        <ul>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
          <li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
        </ul>
      </div>
    </div>
</section>

  • Related