Search code examples
htmlcsspositionalignmentvertical-alignment

Align Logo and navigation button inline centered HTML/CSS


Hi i have the following problem, I have this navigation bar (SEE IMAGE)

and i want to have the logo of the app (currently "AppName") inline with the hamburger menu on the left. so without the weird blank space on top. Any ideas?

EDIT: this is how it needs to be (from adobe XD) IMAGE

My code:

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AppName</title>
    <link rel="stylesheet" href="/app.css">
    <link rel="stylesheet" href="/fontawesome-free-5.15.3-web/css/all.css">
</head>
<body>
    <div class="nav">
        <span onclick="openMenu()"><i class="fas fa-bars"></i></span>
        <h1 class="logo">AppName</h1>
    </div>
</body>
</html>

CSS:

@import url('https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,400;0,700;1,400;1,700&display=swap');

*{
    font-family: 'Rubik', sans-serif;
    margin: 0;
}

.nav{
    background-color: #0A0E44;
    padding: 20px;
    color: white;
}

.fas{
    font-size: 40px;
    padding-left: 20px;
}

.logo{ 
    *display: flex;(Tried this does not work)
    align-items: center; (Tried this does not work)
    justify-content: center;* (Tried this does not work)
}

.navbar{
    *display: inline;* (Tried this does not work)

}

Please help me!

BeldrNl


Solution

  • I fixed it. I added display:inline; to my logo and changed the margin-left to 40% and that did it.

    Thanks!

    CSS:

    display: inline;
    margin-left: 40%;