Reputation: 89
I'm working on a multilingual website and I want to position a fixed language menu div right under its icon. I'm using Bootstrap 3.
<div class="menu-icon pull-right">
<a id="lan-icon" href="#">
<span class="glyphicon glyphicon-globe" aria-hidden="true"></span>
</a>
<div id="list-lan" class="list-lan hidden">
<div class="row">
<ul>
<li><a href="">english</a></li>
<li><a href="">arabic</a></li>
</ul>
</div>
</div>
</div><!-- menu-icon -->
This is how to position it?
div.list-lan {
background: rgba(0,0,0,0.8);
position: fixed;
top: 38px;
right: 0px;
width: 20%;
z-index: 888;
}
Right now the div
is positioned relative to the viewport. How can I position it under its menu item?
Upvotes: 0
Views: 200
Reputation: 683
In order to position and element relative to another you must first position the parent element relative. then you can position the child as absolute
But...If you are using bootstrap why not just use bootstraps nav or navbar
<ul class="nav">
<li class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="glyphicon glyphicon-globe"></i> Language</a>
<ul class="dropdown-menu">
<li><a href="">english</a></li>
<li><a href="">arabic</a></li>
</ul>
</li>
<li class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="glyphicon glyphicon-search"></i> Search</a>
<ul class="dropdown-menu">
<li>Your Code Here for search</li>
</ul>
</li>
</ul>
Upvotes: 1
Reputation: 1683
position:fixed sets the positions relative to the window (as in scrolling won't move the element up or down the view). What you probably want is to set the position:relative. Could you be clearer on what behaviour you want?
Upvotes: 0