Hello fellows,
I am km0! I am constructing my portfolio page, I was trying to for HOURS to put my navbar’s context (home, work, about, etc) with “float: left” for my menus, but it just doesn’t work and I can’t figure out where is the problem? Please help me debug this problem, I will appreciate it very much, thank you!
Your navbar is already on the left I think
My guess is you try to achieve with bootstrap nav since you use the framework.
So I have modified your code;
HTML Section
From
<div id="navbar">
<a href="#kylemyr" class="logo-img" title="Kyle Myr" alt="Kyle Myr">KM</a>
<a href="#about">about</a>
<a href="#featured">featured</a>
<a href="#portfolio">portfolio</a>
<a href="#blog">blog</a>
<a href="#contact">contact</a>
</div>
To
<nav id="navbar" class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="logo-img" href="#kylemyr" alt="Kyle Myr">KM</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#about">about</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#featured">featured</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#portfolio">portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#blog">blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">contact</a>
</li>
</ul>
</div>
</nav>
CSS Section
From
#navbar {
background-color: #333;
position: fixed;
top: 0;
width: 100%;
z-index: 1;
display:block;
transition: top 0.3s;
}
#navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 15px;
text-decoration: none;
font-size: 17px;
}
#navbar a:hover {
background-color: #ddd;
color: black;
}
.logo-img{
border: 2px solid white;
border-radius: 50%;
color: white;
float: left;
padding: 10px 10px 10px 5px;
margin-left: 150px;
margin-top: 6px;
width: 50px;
height: 50px;
font-size: 48px;
}
#kylemyr{
width: 80%;
margin: 0 auto;
margin-shadow: 0px 0px 2px 1px rgba(0,0,0,0.2);
}
To
.navbar{
background-color: #333!important;
z-index: 1;
transition: top 0.3s;
}
#navbar a{
color: #f2f2f2;
font-size: 17px;
text-decoration: none;
}
#navbar a:hover{
background-color: #ddd;
color: black;
}
.logo-img{
color: white;
text-align: center;
border: 2px solid white;
border-radius: 50%;
line-height: 48px;
margin-right: 2em;
width: 50px;
height: 50px;
/* Apply shadow to the text */
text-shadow: 0px 0px 2px 1px rgba(0,0,0,0.2);
/* Apply shadow to the circle */
box-shadow: 0px 0px 2px 1px rgba(0,0,0,0.2);
}
Hope this help.