Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The button of home is not in line with other buttons. there is also a logo with alt text on left of the nav bar

What I have tried:

    <title>Mayuri_Bake
            
        
    
    
    
    
                
    
        
    
        


    <div class="all-content">
        
        
            
            <a class="navbar-brand" href="#" id="logo">
                Mayuri's
                Cake Bake          
            
            
              <span></span>
            
          
            
            </a><div class="collapse navbar-collapse" id="collapsibleNavbar"><a class="navbar-brand" href="#" id="logo">
              </a><ul class="navbar-nav"><a class="navbar-brand" href="#" id="logo">
                </a><li class="nav-item"><a class="navbar-brand" href="#" id="logo">                  </a><a class="nav-link" href="#">Home</a>
                </li>                
                <li class="nav-item dropdown">                    <a href="#" class="nav-link dropdown-toggle" id="navbardrop" data-toggle="dropdown">
                     Category
                    </a>
                    <div class="dropdown-menu">
                        <a href="#" class="dropdown-item">Birthday Cake</a>
                        <a href="#" class="dropdown-item">Chocolate Cake</a>
                        <a href="#" class="dropdown-item">Party Cake</a>
                        <a href="#" class="dropdown-item">Slice Cake</a>
                        <a href="#" class="dropdown-item">Cup Cake</a>
                    </div>
                </li>                
                <li class="nav-item">                  <a class="nav-link" href="#">Galary</a>
                </li>                <li class="nav-item">                  <a class="nav-link" href="#">About</a>
                </li>                <li class="nav-item">                  <a class="nav-link" href="#">Contact</a>
                </li>              </ul>
            </div>
            <div class="icons">
                
                
                
            </div>
          
        

now starts the css file


*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Uchen', serif;
}
.all-content{
    background: #2e1700;
}
/* navbar */
#navbar{
    background-color: #573818;
    padding-left: 60px;
    font-weight: bold;
}
#logo{
    font-size: 23px;
    color: white;
}
#logo img{
    margin-bottom: 15px;
}
.brand-name{
    font-weight: bold;
}
.sub-text{
    margin-top: -8px;
}
.navbar-nav{
    margin-left: 10px;
}
.nav-link{
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 1px black;
    margin-left: 15px;
    transition: 0.5s ease;
}
.nav-link:hover{
    background-color: rgba(161,109,14,1);
    color: white;
    border-radius: 5px;
}
.icons{
    margin-left: 30px;
}
.icons img{
    margin-left: 10px;
    transition: 0.5s ease;
    cursor: pointer;
}
.icons img:hover{
    transform: translateY(-5px);
}
@media screen and (max-width:330px){
    #logo{
        font-size: 15px;
    }
}</div>
Posted
Updated 13-Aug-23 0:11am

1 solution

Your code is a nightmare to figure out exactly what you are trying to do. Your styles is not within the style tag, a div element follows the style closing, very poor indentation, your elements will never display properly.

I have modified your code to work as you expect, from what little information we got -
HTML
<!DOCTYPE html>
<html>
<head>
    <title>Mayuri_Bake</title>
    <link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
    <div class="all-content">
        <nav id="navbar">
            <a class="navbar-brand" href="#" id="logo">
                Mayuri's Cake Bake
                Delicious Homemade Cakes
            </a>
            <div class="collapse navbar-collapse" id="collapsibleNavbar">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="#">Home</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a href="#" class="nav-link dropdown-toggle" id="navbardrop" data-toggle="dropdown">
                            Category
                        </a>
                        <div class="dropdown-menu">
                            <a href="#" class="dropdown-item">Birthday Cake</a>
                            <a href="#" class="dropdown-item">Chocolate Cake</a>
                            <a href="#" class="dropdown-item">Party Cake</a>
                            <a href="#" class="dropdown-item">Slice Cake</a>
                            <a href="#" class="dropdown-item">Cup Cake</a>
                        </div>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Gallery</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">About</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Contact</a>
                    </li>
                </ul>
            </div>
        </nav>
        <div class="icons">
            <!-- Add icons here -->
        </div>
    </div>
</body>
</html>


Your style.css file -
CSS
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Uchen', serif;
}

.all-content {
    background: #2e1700;
}

/* navbar */
#navbar {
    background-color: #573818;
    padding: 15px 0;
    text-align: center;
    font-weight: bold;
}

#logo {
    font-size: 23px;
    color: white;
    text-decoration: none; /* Remove the underline from the link */
    display: block; /* Ensure the entire navbar item is clickable */
}

.sub-text {
    display: block;
    font-size: 12px;
    color: #fff;
}

.navbar-nav {
    margin-top: 10px;
}

.nav-link {
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 1px black;
    margin: 0 15px;
    transition: 0.5s ease;
    text-decoration: none; /* Remove the underline from the link */
}

.nav-link:hover {
    background-color: rgba(161, 109, 14, 1);
    color: white;
    border-radius: 5px;
}

.icons {
    margin-left: 30px;
}

.icons img {
    margin-left: 10px;
    transition: 0.5s ease;
    cursor: pointer;
}

.icons img:hover {
    transform: translateY(-5px);
}

@media screen and (max-width: 330px) {
    #logo {
        font-size: 15px;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900