I encountered an issue with my HTML and CSS code...everything was working smoothly until I decided to add a class name for the <ul>
and <li>
, like this:
<nav class="navContainer">
<ul class="navbar">
<li class="leftSide navItem active"><a class=" home " href="#Home"><i class="fas fa-home"></i><br><span>Home</span></a></li>
<li class="leftSide navItem"><a class=" about scroll" href="#About"><i class="fas fa-id-card"></i><br><span>About Us</span></a></li>
<li class="middle navItem"><a class=" service scroll" href="#Services"><i class="fas fa-bolt"></i><br><span>Our Services</span></a></li>
<li class="middle navItem"><a class=" work scroll" href="#Work"><i class="fas fa-suitcase"></i><br><span>Our work</span></a></li>
<li class="rightSide navItem"><a class=" products scroll" href="#Products"><i class="fas fa-solar-panel"></i><br><span>Our products</span></a></li>
<li class="rightSide navItem"><a class=" contact scroll" href="#Contact"><i class="fas fa-headset"></i><br><span>Contact Us</span></a></li>
</ul>
<nav>
This caused the navbar to appear vertically instead of horizontally. To rectify this, I had to adjust the selectors in the CSS code as follows:
/* header st */
.mainContainer header {
position: fixed;
top: 0;
background-color: #45af0d;
width: 100%;
height: 256px;
}
/* navBar st */
.mainContainer header .navContainer {
display: flex;
justify-content: space-between;
background-color: transparent;
text-transform: uppercase;
font-size: 1.25rem;
font-weight: bolder;
}
.mainContainer header .navContainer ul.navbar {
text-align: center;
background-color: transparent;
min-width: 696px;
list-style: none;
}
...
The classes were named for a jQuery code that handles switching the active navbar during scrolling.
The final result after making these changes can be viewed here: https://i.sstatic.net/pyfkJ.png
The li
elements were not displaying correctly.
I removed all relevant margin-top
properties related to the header, except for the SVG. Despite this, the alignment issue persisted. Am I overlooking something?