'I’m having trouble finding the bug
I am trying to line up this list item directly underneath the hours div tag. My list item is pushed just a little to the right, and I cant seem to find out why. My HTML and CSS skills are beginner.
I did follow from a YouTube video, but don't know what I did wrong.
#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 class="hero container">
<div class="">
<h2>Hours</h2>
<div class="hours">
<ul>
<li><b>Mon-thurs: </b>9am - 5pm<span></span></li>
</ul>
</div>
</div>
</section>
Solution 1:[1]
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 class="hero container">
<div class="">
<h2>Hours</h2>
<div class="hours">
<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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kosh |