需要以<ul>列表样式菜单为中心的帮助</ul>

时间:2013-12-17 16:12:19

标签: css menu navigation html-lists

这是我的网站: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;
}

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

2 个答案:

答案 0 :(得分:1)

您可以在CSS上更改此内容:

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

答案 1 :(得分:0)

这可以帮助您:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">