gpt4 book ai didi

css - 需要帮助将
    列表式菜单居中

转载 作者:行者123 更新时间:2023-11-28 10:17:09 24 4
gpt4 key购买 nike

这是我的网站:http://sousvi.zymichost.com .

我有一个列表样式的菜单(主页、参与、竞赛等),我试图将其置于页面中央,以便它在台式计算机和移动设备(iPhone、iPad)上正确显示。我已将菜单 div 的宽度调整为菜单本身的确切像素数量。它在电脑上看起来很好,但在 iPad 或 iPhone 上却不行。我不想创建移动网站,我只想将菜单居中放置在页面上。这是下面的 HTML 和 CSS。

<div id="navigation">
<div id='cssmenu'>
<ul>
<li class='active'><a href='../index.html'><span>Home</span></a></li>
<li><a href='../participation.html'><span>Participation</span></a></li>
<li><a href='../competition.html'><span>Competition</span></a></li>
<li><a href='../affiliations.html'><span>Affiliations</span></a></li>
<li class='last'><a href='../contact.html'><span>Contact</span></a></li>
</ul>
</div>
</div>

body {
background: url(img/red.png) top center no-repeat;
background-color: #ececec;
margin: 0;
font-family: SpecialOlympics;
}

@font-face {
font-family: SpecialOlympics;
src: url('font/Ubuntu-R.ttf');
}

#wrapper {
background-color: #CCC;
width: 1000px;
margin-left: auto;
margin-right: auto;
}

.container {
background-color: #CCC;
width: 1000px;
margin-left: auto;
margin-right: auto;
}

#navigation {
width: 1000px;
background-color: #ececec;
border-bottom: 2px solid #e2001a;
}

#header {
background-color: #CCC;
}

#logo {
display: block;
margin-left: auto;
margin-right: auto;
}

#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a {
margin: 0;
padding: 0;
position: relative;
}
#cssmenu {
height: 49px;
background: #ececec;
width: 1000px;
margin-left: auto;
margin-right: auto;
}
#cssmenu:after,
#cssmenu ul:after {
content: '';
clear: both;
}
#cssmenu a {
background: #ececec;
color: #000;
display: inline-block;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 12px;
line-height: 49px;
padding: 0 30px;
text-decoration: none;
}
#cssmenu ul {
list-style: none;
}
#cssmenu > ul {
float: left;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu > ul > li > a {
color: #000;
font-size: 18px;
}
#cssmenu > ul > li:hover:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #e2001a;
margin-left: -10px;
}
#cssmenu > ul > li.active:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #e2001a;
margin-left: -10px;
}
#cssmenu > ul > li.active > a {
-moz-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
background: #e2001a;
color: #fefefe;
}
#cssmenu > ul > li:hover > a {
background: #ececec;
-moz-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
color: black;
}
#cssmenu > ul > li.active:hover > a {
background: #e2001a;
color: #fefefe;
}
#cssmenu .has-sub {
z-index: 1;
}
#cssmenu .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#cssmenu .has-sub ul li {
*margin-bottom: -1px;
}
#cssmenu .has-sub ul li a {
background: #e2001a;
border-bottom: 1px dotted #ff1631;
filter: none;
font-size: 11px;
display: block;
line-height: 120%;
padding: 10px;
color: #ffffff;
}
#cssmenu .has-sub ul li:hover a {
background: #af0014;
}
#cssmenu .has-sub .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#cssmenu .has-sub .has-sub ul li a {
background: #af0014;
border-bottom: 1px dotted #ff1631;
}
#cssmenu .has-sub .has-sub ul li a:hover {
background: #950011;
}

#footer {
height: 50px;
overflow: hidden;
padding-bottom: 30px;
background-color: #ccc;
border-top: #e2001a 2px solid;
float: left;
margin-top: 15px;
}

#footer p {
line-height: normal;
text-align: center;
text-shadow: 1px 1px 0px #FFFFFF;
color: #696969;
font-size: 13px;
font-family: Tahoma, Geneva, sans-serif;
}

#footer a {
text-decoration: underline;
color: #696969;
}

#footer a:hover {
text-decoration: none;
color: #000000;
}

.content {
width: 625px;
float: left;
padding-top: 15px;
padding-left: 15px;
padding-bottom: 12px;
padding-right: 15px;
overflow: hidden;
background-color: #FFF;
margin-left: 15px;
margin-top: 15px;
}

.content p {
margin-top: 0;
color: #494949;
}

.content p.last {
margin-bottom: 8px;
}

.content a {
color: #e2001a;
text-decoration: none;
font-weight: bold;
}

.content a:hover {
color: #494949;
text-decoration: underline;
}

.content li {
color: #494949;
}

.sidebar {
width: 270px;
padding-top: 15px;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 12px;
overflow: hidden;
background-color: #FFF;
margin-top: 15px;
margin-left: 15px;
margin-bottom: 15px;
}

#bodyp {
background-color: #CCC;
overflow: hidden;
}

h1 {
margin: 0;
padding: 0;
text-align: center;
}

h2 {
margin: 0;
padding: 0;
text-align: center;
}

.boxcontent {
width: 670px;
float: left;
}

.boxsidebar {
float: left;
}

任何和所有帮助将不胜感激!谢谢!

最佳答案

您可以在您的 CSS 上更改它:

#cssmenu > ul {
/*float:left --- Remove this*/
display:inline-block; /*Add this*/;
}
#cssmenu {
text-align:center; /*Add this*/
}

关于css - 需要帮助将 <ul> 列表式菜单居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20639114/

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