gpt4 book ai didi

html - 如何将标题放在导航栏的中间?

转载 作者:行者123 更新时间:2023-11-28 01:18:25 26 4
gpt4 key购买 nike

如何设置我的导航和标题的位置,使其看起来像这样?

enter image description here

我一直在尝试在 google 和 stack overflow 上搜索,但找不到任何东西。

这是我的代码,谢谢。

body
{
background-image: url('bground.png');
text-align: center;
font-family: arial;
}

#wrap { margin: 0 auto; width: 700px; }

#header{

}


ul, li, a{
display: inline;
list-style: none;
font-family: arial;
color: #000000;
text-decoration: none;
font-size: 25px;
}

li, a:hover{
display: inline;
list-style: none;
font-family: arial;
font-size: 25px;
color: #ffdc99;
}

#content{
background: #ffffff;
max-width: 800px;
margin-left: auto;
margin-right: auto;
text-align: center;
vertical-align: bottom;
}

/* Edits */
#header,
#content{ clear: both; }

#header,
#header h1,
#header #nav { float: left; }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gullible</title>
<link rel="stylesheet" href="style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>

<div id="wrap">

<div id="logo">
<h1>Gullible</h1>
<ul id="nav">
<li><a href="home.html">Home</a></li>
<li><a href="shop.html">Shop</a></li>
<li><a href="home.html">Visit</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>

<div id="content">
<h1></h1>
</div>

</div>

<footer>
<h2>Gullible</h2>
<ul>
<li>Home</li>
<li>Shop</li>
<li>Visit</li>
<li>Contact</li>
</ul>
</footer>
</body>
</html>

最佳答案

试试 Flexboxjustify-content: space-around;

Flex items are evenly distributed so that the space between two adjacent items is the same. The empty space before the first and after the last items equals half of the space between two adjacent items.

ul {
display: flex;
list-style-type: none;
justify-content: space-around;
align-items: center;
border-bottom: 2px solid black;
padding: 0;
}

.logo {
font-size: 30px;
font-weight: bold;
padding: 10px 0;
}

a {
text-decoration: none;
color: black;
}
<ul>
<li><a href="">LINK</a></li>
<li><a href="">LINK</a></li>
<li class="logo"><a href="">LOGO</a></li>
<li><a href="">LINK</a></li>
<li><a href="">LINK</a></li>
</ul>

关于html - 如何将标题放在导航栏的中间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34798058/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com