1

我正在尝试实现这样的导航系统:

在此处输入图像描述

我尝试从像这样的简单 HTML 和 CSS 结构开始,但直到现在才成功。

     <div id="categoryWrapper">
            <ul>
                <li><a href="#"><img src="/assets/sample.png"><span>Diyet</span></a></li>
                <li><a href="#"><img src="/assets/sample.png"><span>Diyet</span></a></li>
                <li><a href="#"><img src="/assets/sample.png"><span>Diyet</span></a></li>
            </ul>
    </div>


#header #center #categoryWrapper ul{
    width:300px;
    margin:0 auto;
    height: 100%;

}

#header #center #categoryWrapper ul li{
    display:inline-block;
    height:54px;
    list-style-type: none;
}

#header #center #categoryWrapper ul li a{
    display:inline-block;
    position:relative;
}

#header #center #categoryWrapper ul li a img{
    position:absolute;
    top:-2px;
} 

#header #center #categoryWrapper ul li span{
    display:inline-block;
    position:relative;
    top:10px;
}
4

4 回答 4

2

这是一个演示:http: //jsbin.com/uruqur/1/edit

基本造型是

#categoryWrapper ul { 
  margin: 0; 
  padding: 0;  /* reset margin/padding */
  text-align: center;
}


#categoryWrapper li { 
 display: inline-block;
}

然后最重要的是,您可以添加任何需要的填充/颜色来匹配您的设计。

于 2012-10-16T19:24:48.733 回答
2

你试过<div>里面<li>吗?
像这样的东西(未经测试):

<ul>
<li>

<div id="image"><a href="#"><img src="/assets/sample.png"/></a></div>
<div class="clear"></div>
<div id="text"><a href="#">Diyet</a></div>

</li>
</ul>


#image{
float:none;
margin:0 auto; //for center alignment but you have to define the width
position:relative;
width:20px; //your img width here
}

#text{
float:none;
margin:0 auto;
position:relative;
width:30px; //your text width here
}

ul,
li{
margin:0;
padding:0;
}

.clear{
clear:both;
}


让我们知道它是否有效。

于 2012-10-16T19:20:25.930 回答
2

试试这个 -演示

#categoryWrapper ul{
    width:300px;
    margin:0 auto;
    height: 100%;
    background: #333;
    padding: 10px 0 5px;
}

#categoryWrapper ul li {
    display:inline-block;
    height:54px;
    list-style-type: none;
    width: 70px;
    text-align: center;
}

#categoryWrapper ul li a{
    display:inline-block;
    color: #fff;
    text-decoration: none;
}

#categoryWrapper ul li span{
    display:block;
    margin-top: 5px;
}
于 2012-10-16T19:21:19.947 回答
0

你可以这样做:

     <div id="categoryWrapper">
            <ul>
                <li><a href="#"><img src="/assets/sample.png"><span>Diyet</span></a></li>
                <li><a href="#"><img src="/assets/sample.png"><span>Diyet</span></a></li>
                <li><a href="#"><img src="/assets/sample.png"><span>Diyet</span></a></li>
            </ul>
    </div>

#categoryWrapper {
    position:relative;
    width:363px;
    height:59px;
    padding:0 15px;
    background-color:#414141;
}

#categoryWrapper ul li {
    display:block;
    float:left;
    margin-left:25px;
    /** for test without image **/
    height:50px;
    width:50px;
    background-color:red;
}
于 2012-10-16T19:21:58.340 回答