dimanche 23 mai 2021

logo float on basic responsive nav

I am trying to place my image logo in the right-up corner (semi lang problem) but when I'm adding " float: right" to my .logo class in CSS it's mixing my js function and make the navigation bar look very bad. I didn't upload my images yet but any other hamburger-menu-icon and logo will fit. What would you do? Thank you all that's my HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Title</title>
</head>
<body>

<nav class="navbar">
        <span class="navbar-toggle" id="js-navbar-toggle">
            <img src="menuicon.png" alt="">
        </span>
    <a href="#" class="logo"><img src="logo-blue.png"></a>
    <ul class="main-nav" id="js-menu">
        <li>
            <a href="#" class="nav-links">Home</a>
        </li>
        <li>
            <a href="#" class="nav-links">Products</a>
        </li>
        <li>
            <a href="#" class="nav-links">About Us</a>
        </li>
        <li>
            <a href="#" class="nav-links">Contact Us</a>
        </li>
        <li>
            <a href="#" class="nav-links">Blog</a>
        </li>
    </ul>
</nav>
<script>
let mainNav = document.getElementById('js-menu');
let navBarToggle = document.getElementById('js-navbar-toggle');

navBarToggle.addEventListener('click', function () {
mainNav.classList.toggle('active');
});
</script>
</body>
</html>

CSS:

* {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}
body {
    font-family: 'Josefin Sans', sans-serif;
}
.navbar {
    background-image: url("bg-mob.png");
    background-size: 100vw;
    font-size: 18px;
    /*background-image: linear-gradient(260deg, #2376ae 0%, #c16ecf   100%);*/
    border: 1px solid rgba(0, 0, 0, 0.2);
    padding-bottom: 10px;
}
.main-nav {
    list-style-type: none;
    display: none;
}
.nav-links, .logo {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);

}


.main-nav li {
    text-align: center;
    margin: 15px auto;


}
.logo {
    display: inline-block;
    font-size: 22px;
    margin-top: 10px;
    margin-left: 20px;
    /*margin-right: auto;*/


}
.logo img {
    width: 150px;
/*background-color: white;*/
}
.navbar-toggle {
    position: absolute;
    top: 15px;
    left: 20px;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    font-size: 24px;
}
.active {
    display: block;
}



Aucun commentaire:

Enregistrer un commentaire