徽标和菜单未附加。

huangapple go评论56阅读模式
英文:

Logo and menu is not attached

问题

我刚刚开始学习HTML和CSS,现在我有一个任务要创建一个简单的网站,但是每当我向下滚动页面时,我的标志和菜单栏都会下移。有人可以帮助我解决这个问题吗?我的带<li>标签的点在网站上也不显示。

这是我的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;
}
<!-- HTML的基本结构和与CSS的链接代码 -->
<!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>
    <!-- 用于显示菜单等的代码 -->
    <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>
英文:

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 &lt;li&gt; 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: &#39;Poppins&#39;, 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: &#39;Poppins&#39;, 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;
}
&lt;!--Grundmallen f&#246;r html samt kopplingskoderna till css mallen--&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;sv&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot;&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
&lt;title&gt;HoS&lt;/title&gt;
&lt;link rel=&quot;icon&quot; href=&quot;mapp/webbfvisual/Bilder/logo1.jpg&quot;&gt;
&lt;link rel=&quot;apple-touch-icon&quot; href=&quot;mapp/webbfvisual/Bilder/logo1.jpg&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;index.css&quot;&gt;
&lt;link href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;link rel=&quot;stylesheet&quot;
href=&quot;https://cdn.jsdelivr.net/npm/boxicons@latest/css/boxicons.min.css&quot;&gt;
&lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot;&gt; 
&lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin&gt; 
&lt;link href=&quot;https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,500;1,600&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!--Koderna f&#246;r att f&#229; fram menyn m.m.--&gt;
&lt;header&gt;
&lt;a href=&quot;#&quot; class=&quot;logo&quot;&gt;&lt;img src=&quot;mapp/webbfvisual/Bilder/logor.jpg&quot; width=&quot;250&quot; alt=&quot;&quot;&gt;&lt;/a&gt;
&lt;ul class=&quot;navbar&quot; id=&quot;meny&quot;&gt;
&lt;li&gt;&lt;a href=&quot;index.html&quot;&gt;Hem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;omoss.html&quot;&gt;Inf&#246;r k&#246;p&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;skotselrad1.html&quot;&gt;Sk&#246;tselr&#229;d&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;Bilder.html&quot;&gt;Bilder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;kontaktaoss.html&quot;&gt;Kontakta oss&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;main&quot;&gt;
&lt;a href=&quot;loggain.html&quot; class=&quot;user&quot;&gt;&lt;i class=&quot;fa-regular fa-user&quot;&gt;&lt;/i&gt;Logga in&lt;/a&gt;
&lt;a href=&quot;registrera.html&quot;&gt;Registrera&lt;/a&gt;
&lt;/div&gt;

I tried to change in my CSS stylesheet.

答案1

得分: 1

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 are 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!

英文:

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!

huangapple
  • 本文由 发表于 2023年4月11日 07:41:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75981488.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定