gpt4 book ai didi

html - 如何让所有列表项的宽度相等?

转载 作者:太空宇宙 更新时间:2023-11-03 20:48:52 25 4
gpt4 key购买 nike

我希望每个 ul 元素的导航栏宽度相等。我已经为 ul.navbar aul.navbar li 尝试了 Width:100%。 JSfiddle:http://jsfiddle.net/HeyItsProdigy/a2zVr/

CSS:

@charset "utf-8";
/* Elements */

body {
margin:0;
padding:0;
background-image:url(main%20bg.jpg)
}

ul {
padding:0;
margin:0;
}

/* End of elements */




/* Id's */

#container {
margin-left:auto;
margin-right:auto;
width:1000px;
}

#body {
border:5px solid #CF0;
width:1000px;
height:1000px;
background-image:url(middle%20bg.png);
}

#navbar {
position:relative;
top:12px;
text-align:center
}

/* End of is's */




/* Classes */

.navbar {
list-style:none;
}

ul.navbar li {
display:inline;
margin:0;
padding:0px;
text-align:center;
}

ul.navbar a {
background-color:#00CCFF;
padding:10px;
margin:0px;
text-decoration:none;
color:#CF0;
border-radius:100px;
border:2px solid white;
}

ul.navbar a:hover {
background-color:#00FFFF;
padding:10px;
margin:0px;
}

/* End of classes */

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link rel="stylesheet" type="text/css" href="style.css" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>

<script>
<!--



//-->
</script>

</head>

<body>
<div id="container">
<div id="body">
<div id="navbar">
<ul class="navbar">
<li><a href="index.html">Blog</a></li><li><a href="index.html">Photos</a></li><li><a href="index.html">Home</a></li><li><a href="index.html">Videos</a></li><li><a href="index.html">About</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>

最佳答案

设置内部 anchor 为

ul.navbar a {
display: inline-block;
width: 80px;
}

为您的内容设置足够长的宽度。

http://jsfiddle.net/vrFx7/1/

关于html - 如何让所有列表项的宽度相等?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18103974/

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