导航栏与正文背景位置absolutecss冲突

时间:2021-02-23 19:34:05

标签: javascript html css

我的 css 问题阻碍了我的进步,我是 html 和 css 的业余爱好者,我需要资深人士的帮助。

问题是把背景放在绝对位置,这样背景不会向两边扩展,但是我随便创建了一个导航栏,和背景的绝对位置冲突,很奇怪,是有什么办法可以解决这个问题吗?

打印:PRINT1 打印:out screen 打印:As you can see, the navbar is back to normal, but the background is clumsy, that's why I'm breaking my head, is there any way to make a navbar with a background in "body" with absolute position?

完整的 HTML 代码:

<!doctype html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Forbidden Series</title>
    
<link rel="stylesheet" type="text/css" href="css/estilos.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@1,600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>

<body>
    
    <!--logo-->
    <header id="forbiddenlogo"><h1><font color="#600103">Forbidden</font> <font color="#FFFFFF">Series</font></h1></header>
        
    <!--navbar-->
    <nav id="navbar">
        <ul>
            <li><a href="#home">Home</a></li>
            <li><a href="#loja">Loja</a></li>
            <li><a href="#staff">Staff</a></li>
            <li><a href="#eventos">Eventos</a></li>
            <li><a href="#login">Login</a></li>
            </ul>
    </nav>
    
    <!--container-->
    <div id="container">
    
    </div>
</body>
</html>

来自我网站的完整 CSS 代码:

/* CSS Document */

@font-face{
    font-family: "8 Bit Madness";
    src: url("../fonts/8-Bit Madness.ttf");
}

@font-face{
    font-family: "8 BIT WONDER";
    src: url("../fonts/8-BIT WONDER.TTF");
}

body{
    position: absolute;
    padding: 0;
    margin: 0;
    background-image: url("../img/Screenshot_1.png");
    background-repeat: no-repeat;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

#container{

}
    
#navbar{
    position: relative;
    background-color: black;
}

#navbar ul{
    
}

#navbar ul li{
    display: inline;
}

#navbar ul li a{
    
}

#forbiddenlogo{
    position: relative;
    font-size: 25px;
    font-family: "8 BIT WONDER";
    -webkit-text-stroke: 1px black;
    bottom: 10px;
    left: 30px;
}

#forbiddenlogo a{
    text-decoration: none;
    font-style: normal;
}

0 个答案:

没有答案