Search code examples
htmlcssnavbarmenubar

Logo and menu is not attached


Im new to html and css, right now I have a assignment to build a simple website but my logo and menubar are moving down when ever im scrolling down the page. Can someone help me with this issue? My dots with the <li> tag also doesn't show on the website.

I have tried to change in my css stylesheet.

This is my CSS & HTML:

*{
padding: 0;
margin: 0;
box-sizing: border-box;
text-decoration: none;
list-style: none;
}
:root{
    --bg-color: linear-gradient(#dbd7d6 0%, #787878 120%);
    min-height: 175vh;
    --text-color: #fff;
    --main-color: #0b0d0b;
}
body{
    min-height: 100vh;
    background: var(--bg-color);
    color: var(--text-color);
}
header{
    position: fixed;
    width: 100%;
    font-family: 'Poppins', sans-serif;
    top: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    transition: all .50s ease;
}
.container{
    width: 80%;
    margin: auto;
    overflow: hidden;
    font-size: 20px;
}
.logo{
    display: flex;
    align-items: center;
    padding-left: 4%;
    padding-top: 2%;
}
.navbar{
    display: flex;
}
.navbar a{
    color: var(--text-color);
    font-size: 1.2rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    padding: 5px 0;
    margin: 0px 30px;
    transition: all .50s ease;
}
.navbar a:hover{
    color: #D3D0CF;
}
.navbar a.active{
    color: var(--main-color);
}
.main{
    display: flex;
    align-items: center;
}
.main a{
    margin-right: 25px;
    margin-left: 10px;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all .50s ease;
}
<!--Grundmallen för html samt kopplingskoderna till css mallen-->
<!DOCTYPE html>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HoS</title>
    <link rel="icon" href="mapp/webbfvisual/Bilder/logo1.jpg">
    <link rel="apple-touch-icon" href="mapp/webbfvisual/Bilder/logo1.jpg">
    <link rel="stylesheet" type="text/css" href="index.css">

    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet">

    <link rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/boxicons@latest/css/boxicons.min.css">
  <link rel="preconnect" href="https://fonts.googleapis.com"> 
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> 
  <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,500;1,600&display=swap" rel="stylesheet">

</head>
<body>

<!--Koderna för att få fram menyn m.m.-->
    <header>
        <a href="#" class="logo"><img src="mapp/webbfvisual/Bilder/logor.jpg" width="250" alt=""></a>

        <ul class="navbar" id="meny">
            <li><a href="index.html">Hem</a></li>
            <li><a href="omoss.html">Inför köp</a></li>
            <li><a href="skotselrad1.html">Skötselråd</a></li>
            <li><a href="Bilder.html">Bilder</a></li>
            <li><a href="kontaktaoss.html">Kontakta oss</a></li>
        </ul>

        <div class="main">
        <a href="loggain.html" class="user"><i class="fa-regular fa-user"></i>Logga in</a>
        <a href="registrera.html">Registrera</a>
        </div>

I tried to change in my CSS stylesheet.


Solution

  • The thing that is causing your menu to move down with scrolling is the following:

    header {
      position: fixed;
    }
    

    You can either delete it or change it to a different value.

    For your second question, the missing dots is due to the following code:

    * {
      list-style: none;
    }
    

    That is stopping your lists from having any decorative dots, etc. Remember the '*' means all elements in the html.

    Hope that helps!