KesaVan
KesaVan

Reputation: 1031

Sub menu have to appear at the starting point as above div

Here is my code in FIDDLE

Here i have a demo div, If i select the menu product it should always select the sub menu starting like the above Demo div's start Point.

Here is my code.

CSS code for the sub menu:

ul li ul {
display: none;
width: 300px;
position: absolute;
left: 0;
margin-left: 8px;
}

Did i missed anything in my code.

Upvotes: 0

Views: 38

Answers (3)

Oriol
Oriol

Reputation: 288260

Try this:

ul{
    position: relative;
}
ul li ul{
    margin-left: 0;
}

Demo

Upvotes: 1

Domain
Domain

Reputation: 11808

When you write position:absolute it take position relative to your browser window ,try position:relative whic takes position relative to its parent

ul li ul {
display: none;
width: 300px;
position: relative;
left: 0;
margin-left: 0px;
}

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114377

ul li{
   float: left;
   width: 100px;
   text-align: center;
   position:relative; <---- add this
}

position:relative sets the origin point for absolutely-positioned child elements.

Upvotes: 1

Related Questions