【发布时间】:2021-10-25 19:06:39
【问题描述】:
我正在建立一个站点,我想将菜单与徽标(图像)放在同一行,问题是菜单放在下面......我认为我的 css 代码有几个矛盾这会阻止菜单转到正确的位置。简而言之,我想创建一个标头,左侧带有徽标,菜单居中!
这是我的 HTML 代码:
<!DOCTYPE HTML>
<html lang=fr_FR>
<head>
<meta charset="UTF-8"></meta>
<link rel="stylesheet" type="text/css" href="styles.css">
<title>STADE BRESTOIS 29 - LE SITE OFFICIEL</title>
</head>
<body>
<div class="navigation">
<a href="#" class="logo" ><img src="logo_header.png" id="logo_header"></a>
<div class="header">
<header id="header-center">
<ul id="menu">
<li id="element">
<a href="#">Pro</a>
</li>
<li id="element">
<a href="#">Formation</a>
</li>
<li id="element">
<a href="#">Club</a>
</li>
<li id="element">
<a href="#">Association</a>
</li>
<li id="element">
<a href="#">Féminines</a>
</li>
</ul>
</header>
</div>
</div>
</body>
</html>
这是我的 CSS 代码:
@charset "utf-8";
@font-face{
font-family: 'nagoda';
src: url('Nagoda.woff') format('woff'),
url('Nagoda.otf') format('otf'),
url('Nagoda.ttf') format('ttf');
font-weight: normal;
font-style: normal;
}
* {
box-sizing: border-box;
scroll-behavior: smooth;
}
#logo_header{
height: 110px;
width: 110px;
position: relative;
text-decoration: none;
margin-left: 54px;
margin-top: 25px;
}
ul {
text-align: center;
}
#menu{
font-family: 'nagoda';
font-size: 25px;
text-decoration: none;
list-style: none;
list-style-type: none;
align-items: center;
}
#header{
overflow: hidden;
background: none;
padding: 20px 10px;
padding-top: 695px;
}
.header a {
float: left;
color: #383838;
text-align: center;
padding: 12px;
text-decoration: none;
font-size: 25px;
line-height: 15px;
border-radius: 5px;
margin: 70px;
}
.header a:hover {
background-color: #ed1c24;
color: white;
}
.header a.active {
background-color: #ed1c24;
color: white;
}
li {
line-height: normal;
}
.header-center {
position: relative;
float: center;
height: 100px;
width: 400px;
display: flex;
justify-content: center;
top: 0;
left: 0;
right: 0;
margin: 0 auto;
}
@media screen and (max-width: 800px) {
.header a {
float: none;
display: block;
text-align: left;
}
.header-center {
float: none;
}
}
body {
background-image: url(Image_bg1.png);
background-repeat: no-repeat;
background-position: center center;
background-attachment: local;
background-size: cover;
width: 1440px;
height: 695px;
}
提前感谢那些愿意帮助我的人!
【问题讨论】:
标签: html css navigation header