Drop down menu that show new link on 2 columns - css

I am building my website.
I am pretty new to CSS and i have 2 question.
I managed to make a drop down menu which satisfy me. The problem is that:
1)I want the white margin bottom bar when i mouseover a the 1st group of link inside the box instead than outside. I know there is a command to achieve this, but i need to fix width and height which I don't want.
2) I want the second ul element to be showed like a table with 2 column and a title for each column that is a link in bold. I can't understand why each link has it's own box around him even if i use inline.
THis is my HTML:
<div id="menu">
<ul>
<li>Ispirazioni</li>
<li>Chi Siamo
<ul>
<li>La Storia</li>
<li>Oggi</li>
</ul>
</li>
<li>Articoli
<ul>
<li>Articoli in promozione</li>
<li>Catalogo ></li>
</ul>
</li>
<li>Contatti</li>
</ul>
And this is my CSS:
#menu {
clear:both;
width:100%;
height:64px;
text-align: center;
top:40px; /* I want the menu bar follow the scroll*/
position:fixed; /*and it stay 40px from top */
background: rgba(89,89,172,0.7); /*I want the background is transparent*/
}
#menu ul li{
position:relative; /*I want the menu element is displayed in ROW*/
display:inline;
}
#menu ul li a{
text-decoration:none;
display:inline-block; /*menu element is separated by 20px*/
padding:20px;
}
#menu ul ul{
display: none; /*menu is hidden*/
position:absolute; /* position depends from the first ul*/
margin:0;
padding:0;
text-align:left;
}
#menu ul ul li{
display:inline; /*my submenu width*/
width:300px
}
#menu ul ul li a{
width:300px;
padding:2px;
font-size:12px;
}
#menu ul li:hover ul {
display: block;
}
#menu ul li:hover ul a{
text-decoration:none;
background:rgba(89,89,172,0.7);
}
#menu ul li:hover > a{
color:blue;
border-bottom: 10px solid #CCC; /* border bottom, i want inside*/
}
#menu ul li:hover ul a:hover{
color:blue;
border-bottom:none;
}
Sorry if my code is poor but i justy started css.
http://jsfiddle.net/ZjLdK/
Here is a fiddle, the white bar that appear when i mouseover the link is outside the box, and i want it inside. And then i want 2 column with clickable link, not a box for each sublink.
And the background always trasparent
THank you so much!

Is this what you were thinking of having done? css:
ul {
position:fixed;
top:40px;
text-align: center;
display: inline;
margin: 0;
list-style: none;
width:100%;
background: rgba(89,89,172,0.7);}
ul li {
display: inline-block;
margin-right: -4px;
padding:0px;
position: relative;
width:20%;
cursor: pointer;}
ul li:hover {
background: #555;
color: #fff;}
ul li ul {
text-align: left;
display: inline;
margin: 0;
opacity: 0;
width:700px;
position:absolute;
top:100%;
left:0px;
visibility: hidden;
list-style: none;}
ul li ul li {
display: inline-block;
width: 300px;
position: relative;
margin:0;
padding:0;
background: #fff;
cursor: pointer;}
ul li ul li:hover {
background:rgba(89,89,172,0.7); }
ul li:hover ul {
opacity: 1;
visibility: visible;}
html:
<ul>
<li>Ispirazioni</li>
<li>Chi Siamo
<ul>
<li>La Storia</li>
<li>Oggi</li>
</ul>
</li>
<li>Articoli
<ul>
<li>Articoli in promozione</li>
<li>Catalogo ></li>
</ul>
</li>
<li>Contatti</li>
</ul>
And here's the fiddle
http://jsfiddle.net/aNVam/230/

Related

Css Dropdown Menu font color

In my drop-down menu the font colour of "li" is white and while "hover" the colour change to black and i have drop-down menu also .When hover the sub menu of my products link, the font colour products(li) changing to white my hover background is also white, here my question, how can I keep the colour of my "li" as black ??
my stylesheet
#menu{width:auto; margin: 0px 0px 0px 0px; background-color: #000; height:32px; float:right; border-radius:0px 0px 10px 10px ;}
#menu ul{list-style-type:none; margin:0px; padding:0px; margin-left:10px;}
#menu ul li{float: left; position: relative; margin-left:0px; height:29px; padding-top:3px;}
#menu ul li:active {color:#000;}
#menu ul li:hover{background-color: #f5f5f5; margin-left:0px; color:#000}
#menu ul li a{color: #fff; padding: 0 16px; line-height:25px; font-size:13px; font-family:arial; display: block; text-decoration:none; margin-left:0px;}
#menu ul li a:hover{background-color: #f5f5f5; margin-left:0px; color:#000;}
#menu ul li ul li{float: none; position: relative; margin-left:0px;}
#menu ul li ul{position: absolute; top:32px; left:0; display: none; background-color: #000; width:150px; margin-left:0px;}
#menu ul li:hover > ul{display: block; margin-left:0px; color:#000;}
#menu ul li ul li a{white-space: nowrap; line-height:25px; margin-left:0px;}
#menu ul li ul li ul{position: absolute; top:0; left:145px; display: none; background-color: #000; width:150px; margin-left:0px;}
my html code
<div id="menu">
<ul>
<li>Home</li>
<li>Profile</li>
<li>Product
<ul>
<li>Has Submenu</li>
<li>Has Submenu</li>
<li>Has Submenu</li>
<li>Has Submenu</li>
<li>Has Submenu</li>
</ul>
</li>
<li>Other Services</li>
<li>Contact Us</li>
</ul>
</div>
Add the following CSS:
#menu ul li:hover > a {
color: #000;
}
The problem was the anchor tag. No matter what color would you set for the li, the anchor tag has style color: #fff.

css make drop down list open to up (opposite direction) and not to down

I have created a dropdown list using css. The drop down list works perfect, opening the menu to down. How can I modified in order to open the menu to up (opposite direction)? make something like drop up list.
This is my html code.
<div id="menu">
<ul>
<li> <?php echo $user_data['name']; ?>
<ul>
<li>Logout</li>
<li>Change Password<li>
<li>Settings<li>
</ul>
</li>
<li> Profile
<ul>
<li>Edit Profile</li>
<li>View Profile</li>
</ul>
</li>
<li> Home </li>
</ul>
</div>
and this is my css.
#menu ul{
padding:0px;
margin:0px;
list-style:none;
}
#menu ul li {
float:left;
}
#menu ul li a:hover{
background:#fff;
color:#333;
}
#menu ul li ul{
position:absolute;
height:0px;
overflow:hidden;
}
#menu ul li ul li{
float:none;
}
#menu ul li:hover ul{
overflow:visible;
}
#menu ul li:hover ul li a{
padding:10px;
}
#menu ul li ul li a{
-webkit-transition:0.3s;
-moz-transition:0.3s;
padding: 0px 10px;
}
http://codepen.io/bjornmeansbear/pen/MwGYZL
The following CSS should help you — it incorporates the "drop-up" and also cleans up a few other things...
#menu {
margin-top: 100px;
}
#menu ul {
padding: 0px;
margin: 0px;
list-style: none;
}
#menu > ul > li {
float: left;
margin: 10px;
position: relative;
}
#menu a { display: block;}
#menu a:hover {
background: #fff;
color: #333;
}
#menu ul li ul {
position: absolute;
height: 0px;
width: 250%;
overflow: hidden;
}
#menu ul li:hover ul {
height: initial;
bottom: 100%;
overflow: visible;
background: lightgray;
}
#menu li li a {
padding: 5px 10px;
}
#menu a {
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
padding: 0px 10px;
}
Basically, if you position the <li> that houses the child <ul> relatively, you can use the absolute position of the <ul> to position it anywhere based directly on its the parent... does that make sense?

Keeping Top level menu in hover state when moving down to sub menus?

I have horizontal menu with 2 sub level. When i move down i would like to keep the Top level menu in hover state.
I have create jsfiddle. link to the JsFiddle
Html Code is :
<div>
<ul id="nav">
<li>Home</li>
<li>Products
<ul class="child">
<li>Hard Drives</li>
<li>Monitors</li>
<li>Speakers
<ul class="child">
<li>10 watt</li>
<li>20 watt</li>
<li>30 watt</li>
</ul>
</li>
<li>Random Equipment</li>
</ul>
</li>
<li>Services
<ul class="child">
<li>Repairs</li>
<li>Installations</li>
<li>Setups</li>
</ul>
</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
And Css code is
> body {
}
#nav li {
list-style:none;
float: left;
}
#nav li a {
display: block;
padding: 8px 12px;
text-decoration: none;
}
#nav li a:hover {
opacity:1;
}
/* Targeting the first level menu */
#nav {
min-width:850px;
background:#fff;
opacity:0.5;
display: block;
height: 34px;
z-index: 100;
position: absolute;
}
#nav > li > a {
}
/* Targeting the second level menu */
#nav li ul {
color: #333;
display: none;
position: absolute;
width:850px;
}
#nav li ul li {
display: inline;
}
#nav li ul li a {
background: #fff;
border: none;
line-height: 34px;
margin: 0;
padding: 0 8px 0 10px;
}
#nav li ul li a:hover {
opacity:1;
}
/* Third level menu */
#nav li ul li ul{
top: 0;
}
ul.child {
background-color:#FFF;
}
/* A class of current will be added via jQuery */
#nav li.current > a {
background: #f7f7f7;
float:left;
}
/* CSS fallback */
#nav li:hover > ul.child {
left:0;
top:34px;
display:inline;
position:absolute;
text-align:left;
}
#nav li:hover > ul.grandchild {
display:block;
}
Can somebody guide me how to do that?
Thanks.
Change the selector from
#nav > li > a:hover
to
#nav > li:hover > a
And
#nav li ul li a:hover
to
#nav li ul li:hover > a

CSS navigation tab gets displayed behind the text instead of in the foreground

I have the following css code:
#menu li {
float:left;
position:relative;
line-height: 3em;
width: 10em;
}
#menu li ul {
position:absolute;
margin-top:0em;
margin-left:.0em;
display:none;
}
#menu ul li ul {
margin-top:0em;
margin-left:0em;
}
#menu a {
display:block;
border-right:1px solid #fff;
background:#3B3B3B;
color:#3B3B3B;
text-decoration:none;
padding:0 0px;
text-align:center;
background: url(images/nav.gif) repeat-x 0 0;
height: 50px;
list-style-type: none;
}
#menu a:hover {
background-color::#3B3B3B3;
color:#fff;
text-align:center;
height: 50px;
list-style-type: none;
}
#menu ul {
border-top:1px solid #fff;
float: right;
list-style-type: none;
}
#menu ul a {
border-right:none;
border-right:1px solid #fff;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
background:#fff;
text-align:center;
background: url(images/nav.gif) repeat-x 0 0;
height: 50px;
}
/* SHOW SUBMENU 1 */
#menu li:hover ul, #menu li.over ul {
display:block;
background:#fff;
}
#menu li:hover ul ul, #menu li.over ul ul {
display:none;
}
/* SHOW SUBMENU 2 */
#menu ul li:hover ul, #menu ul li.over ul {
display:block;
}
and the following HTML code
<div class="shell">
<div class="cl"> </div>
<ul id="menu">
<li>HOME</li>
<li>
CLIENTS
<ul>
<li>CLIENT LIST</li>
The problem I am having is that when the I hover my mouse over the drop down tabs - "CLIENT LIST" - It gets displayed behind the images and text that are on my page. How do I bring it to front?
As I understand your menu is coming under images and text, which are placed on your page. and you want to display this menu over all the content of the page.
If so, then provide a higher z-index value to your menu from all the content.
like: .menutab { z-index : 1000;} where .menutab is a class which is on your menu element.
Edited : make change in this line
/* SHOW SUBMENU 1 */ #menu li:hover ul, #menu li.over ul
{ display:block; background:#fff;}
to
/* SHOW SUBMENU 1 */ #menu li:hover ul, #menu li.over ul
{ display:block; background:#fff; z-index:1000; }
It will solve your problem.
check this DEMO

CSS Submenu background on hover

I want to make a small website for myself and so I ask this question as a beginner. I cannot succeed to have the submenu contain another background when hovering the main menu.
HTML:
<div id="nav">
<ul class="sub1">
<li><h2>Home</h2></li>
<li><h2>About</h2><!---id="onlink"--->
<ul class="sub2">
<li>Us</li>
<li>Our product</li>
</ul>
</li>
</ul>
</div>
CSS:
#nav{
width:100%;
height: 60px;
padding-top: 20px;
padding-bottom: 10px;
}
#nav ul{
margin:0;
padding:0;
width: 60%;
margin: auto;
}
#nav ul li{
margin:0;
padding:0;
list-style: none;
float:left;
position:relative;
background:transparent url(EN/Button_menu_unselected.png);
}
#nav ul li ul li{
background:aqua; /*Test that doesn't work*/
}
#nav ul li a{
text-align:center;
text-decoration:none;
height:20px;
width:100px;
padding:10px;
display:block;
color:#003300;
}
#nav ul ul{
position:absolute;
visibility:hidden;
}
#nav ul li:hover ul{
visibility:visible;
}
#nav ul li:hover a{
background-image: url(EN/Button_menu_rollover.png);
}
The drop down items get the same format as the button called "Button_menu_rollover", which gives me a very bad result.
The code:
#nav ul li:hover a{
background-image: url(EN/Button_menu_rollover.png);
}
is applied to all elements and sub-elements.
This fixes it, but this code does not work on IE6:
#nav ul li:hover > a{
background: #fff;
}
Or you may use Javascript for HOVER effect to get exact results.

Resources