我尝试用图像描述我的问题。
*这是我喜欢的
*这就是我得到的:
HTML
<div class="header">
<ul class="menu">
<li>Home</li>
<li>Contant</li>
</ul>
</div>
<div class="container>
....
</div>
CSS
.header {
background: #77bbf5;
width : 100px;
height: 75px;
line-height: 75px;
}
.menu {
float: left;
list-style-type: none;
background: #955d5d;
position: absolute
}
.menu li {
display: inline;
position: relative;
}
.menu li a {
float: left;
width: 35px;
height: 35px;
line-height: 35px;
margin-left: 12px;
margin-top: 50px;
text-align: center;
display: inline-block;
}
我尝试过,尝试过并尝试过,请帮忙。
如何解决这个问题?
答案 0 :(得分:1)
试试这个:
<div class="header">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div class="container">
....
</div>
CSS:
.header {
background: #32aaff;
width : 400px;
height: 75px;
line-height: 75px;
}
ul {
width:300px;
height:40px;
list-style-type: none;
background: #955d5d;
margin-top:50px;
position:absolute;
margin-left:30px;
}
ul li {
width:80px;
height:30px;
margin:10px;
float:left;
background: #d2d2d2;
}
ul li a {
float: left;
width: 35px;
height: 35px;
line-height: 35px;
margin-left: 12px;
text-align: center;
display: inline-block;
}
.container{
width:400px;
height:500px;
background:#323232;
}
请参阅Here
答案 1 :(得分:0)
这里有solution:
HTML
<div class="header">
<ul class="menu">
<li>Home</li>
<li>Contant</li>
</ul>
</div>
<div class="container">
...
</div>
CSS
.header{
background: #77bbf5;
width : 100%;
height: 40px;
line-height: 40px;
padding-left: 30px;
position: relative;
}
.menu {
list-style-type: none;
background: #955d5d;
position: absolute;
left: 100px;
top: 20px;
margin: 0;
padding: 0 10px;
}
.menu li{
display: inline;
}
.menu li a {
width: 35px;
height: 35px;
line-height: 35px;
padding: 20px;
text-align: center;
}
.container{
background: #dfd3d3;
padding: 30px;
}