user3281766
user3281766

Reputation: 33

Menu Floating problems

I try to describe my problem using images.

*Here is what I like to have

enter image description here

*This is what I'm getting:

enter image description here

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;
}

i tried, tried and tried, please help.

How to fix that ?

Upvotes: 1

Views: 91

Answers (2)

Nabaroa
Nabaroa

Reputation: 1

Here you have a 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;
}

Upvotes: 0

Hamid Talebi
Hamid Talebi

Reputation: 1318

try this:

<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;
}

see Here

Upvotes: 1

Related Questions