.head_menu
{
height:30px;
line-height:30px;
color:#FFF;
position:absolute;
font-family:Arial;
font-size:15px;
right:15px;
z-index:2;
top:3px;
}
.head_menu ul
{
padding:0px;
margin:0;
list-style:none;
}
.head_menu ul li
{
padding:0;
margin:0;
float:left;
}
.head_menu ul li a
{
color:#FFF;
display:block;
text-decoration:none;
}
.head_menu ul li a:hover
{
color:#FFF;
text-decoration:underline;
text-shadow: 0 0 10px #FFF;
}
.head_menu ul li ul a:hover
{
background:#e17310;
}
.head_menu ul li ul
{
display: none;
width: auto;
position:absolute;
top:30px;
padding:0px;
margin:0px;
}
.head_menu ul li:hover ul
{
display:block;
position:absolute;
margin: 0;
padding: 0;
}
.head_menu ul li:hover li
{
float: none;
list-style:none;
margin:0px;
}
.head_menu ul li:hover li
{
background:#e7a017;
}
.head_menu ul li:hover li a
{
color: #FFF;
padding:0 20px;
display:block;
width:80px;
}
.head_menu ul li li a:hover
{
color:#FFF;
}
thats my code and the drop down menu looks like this.
http://s18.postimg.org/612nvikmh/Untitled.jpg
(sorry if its flipped idk why but when I uploaded it it flipped that way)
can you guys help me move it to the left to show the full menu? I've been trying to solve this for an hour now and can't seem to find a fix for it on the internet, and I am now very confused as hell.
thanks everyone!
.head_menu
{
height:30px;
line-height:30px;
color:#FFF;
position:absolute;
font-family:Arial;
font-size:15px;
left:15px;
z-index:2;
top:3px;
}
Try to put the menu in a div container and Then set this container float:left;
Or you could set width and use margin:0 auto;to center it.
And you need to delete the position: absoulte;from .head_menu
http://jsfiddle.net/Ucvbu/
What you can do is, we can set the negative value to the padding, so set the negative value to margin-right. Then increase the right padding to the so that it dropdown is aligned correctly.
.head_menu ul li:hover ul
{
display:block;
position:absolute;
margin-right:-20px;
padding: 0;
}
.head_menu ul li:hover li a
{
color: #FFF;
padding:0 20px;
display:block;
width:80px;
padding-right:10px;
}
Related
I'm currently working on my website and I have an existing navigation bar. The problem is that I have too much information to share on one page. That's why I'd like to implement a dropdown menu in the existing navigation bar. I've tried many many things but it all seems to screw up my lay-out of the css or it completely deletes the navigation bar.
I got an exisiting code for a dropdown menu but I simply am not able to blend it with the existing css code. I got this code from the internet, it is not my property.
My HTML:
<div id="menu">
<ul>
<li class="current_page_item">Home</li>
<li>Onze service</li>
<li>Ons team</li>
<li>Prijzen</li>
<li>Contact</li>
</ul>
</div>
My CSS:
#menu
{
position: absolute;
right: 0;
top: 1em;
}
#menu ul
{
display: inline-block;
}
#menu li
{
display: block;
float: left;
text-align: center;
line-height: 60px;
}
#menu li a, #menu li span
{
display: inline-block;
margin-left: 1px;
padding: 0em 1.5em;
letter-spacing: 0.10em;
text-decoration: none;
font-size: 1.0em;
text-transform: uppercase;
outline: 0;
color: #212121;
background: #ECECEC;
}
#menu li:hover a, #menu li.active a, #menu li.active span
{
}
#menu .current_page_item a
{
background: #E24E2A;
color: #FFF;
}
#menu .icon
{
}
Drop down menu:
#primary_nav_wrap
{
margin-top:15px
}
#primary_nav_wrap ul
{
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul a
{
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#primary_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul li.current-menu-item
{
background:#ddd
}
#primary_nav_wrap ul li:hover
{
background:#f6f6f6
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary_nav_wrap ul ul li
{
float:none;
width:200px
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary_nav_wrap ul ul ul
{
top:0;
left:100%
}
#primary_nav_wrap ul li:hover > ul
{
display:block
}
Thanks in advance!
Your navigation wrapper is menu whereas in the CSS from online it is primary_nav_wrap, so swap instances of these to menu.
In the html itself nested unordered list elements is used for the drop-downs, so add these under the list element where you need a drop-down.
Html:
<div id="menu">
<ul>
<li class="current_page_item">Home<ul>
<li>sub1</li>
<li>sub2</li>
<li>sub3</li>
</ul>
<li>Onze service</li>
<li>Ons team</li>
<li>Prijzen</li>
<li>Contact</li>
</ul>
</div>
CSS:
#menu ul {
display:inline-block;
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#menu li {
display:block;
float:left;
text-align:center;
line-height:60px
}
#menu li a,#menu li span {
display:inline-block;
margin-left:1px;
padding:0 1.5em;
letter-spacing:.1em;
text-decoration:none;
font-size:1em;
text-transform:uppercase;
outline:0;
color:#212121;
background:#ECECEC
}
#menu .current_page_item a {
background:#E24E2A;
color:#FFF
}
#menu {
margin-top:15px
}
#menu ul a {
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#menu ul li {
position:relative;
float:left;
margin:0;
padding:0
}
#menu ul li.current-menu-item {
background:#ddd
}
#menu ul li:hover {
background:#f6f6f6
}
#menu ul ul {
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#menu ul ul li {
float:none;
width:200px
}
#menu ul ul a {
line-height:120%;
padding:10px 15px
}
#menu ul ul ul {
top:0;
left:100%
}
#menu ul li:hover > ul {
display:block
}
Here is a jsfiddle of the code merged:
https://jsfiddle.net/o51pp5s6/
In the below drop down list, sub menus are getting displayed with lots of space, please see the below chart, Please let me know how do I avoid the space between parent Menu and Child menu.
-----------------------------------------------------------
| PARENT1 |
-----------------------------------------------------------
**SPACE IS HERE**
--------
|CHILD1 |
--------
|CHILD2 |
--------
My CSS Code :-
#navMenu {
margin:0;
padding:0;
}
#navMenu {
margin:0;
padding:0;
}
#navMenu ul{
margin:0;
padding:0;
line-height:30px;
z-index:1;
}
#navMenu li{
margin:0;
padding:0;
list-style:none;
float:left;
position:relative;
background:#8B0F2E;
top: 51px;
left: 10px;
}
#navMenu ul li a {
text-align:center;
font-family:"Comic Sans MS",cursive;
text-decoration:none;
height:30px;
width:150px;
display:block;
color:#FFF;
border:0px solid #FFF;
}
#navMenu ul ul
{
position:absolute;
visibility:hidden;
top:32px;
}
#navMenu ul li:hover ul
{
visibility:visible;
}
#navMenu li:hover
{
background:#09F;
}
#navMenu ul li:hover ul li a:hover
{
background:#CCC;
color:#000;
}
#navMenu a:hover
{
color:#000;
}
.clearFloat
{
clear:both;
margin:0;
padding:0;
}
We are working on tabbed menu. Submenus are not working in chrome but are working in firefox.
body {
background:#FFF;
margin:0;
padding:0;
}
.example {
width:1000px;
height:570px;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
font-family:Times New Roman;
margin:20px auto;
padding:15px;
}
#nav, #nav ul {
background-image:url(../images/tr75.png);
list-style:none;
margin:0;
padding:0;
}
#nav {
height:41px;
padding-left:5px;
padding-top:5px;
position:relative;
z-index:2;
}
#nav ul {
left:-9999px;
position:absolute;
top:37px;
width:auto;
}
#nav ul ul {
left:-9999px;
position:absolute;
top:0;
width:auto;
}
#nav li {
float:left;
margin-right:5px;
position:relative;
}
#nav li a {
background:#AFDCEC;
color:#000;
display:block;
float:left;
font-size:16px;
text-decoration:none;
padding:8px 10px;
}
#nav > li > a {
-moz-border-radius:6px;
-webkit-border-radius:6px;
-o-border-radius:6px;
border-radius:6px;
overflow:hidden;
}
#nav li a.fly {
padding-right:15px;
}
#nav ul li {
margin:0;
}
#nav ul li a {
width:120px;
}
#nav ul li a.fly {
padding-right:10px;
}
#nav li:hover > a, current {
background-color:#659EC7;
color:#000;
}
#nav li.current a {
background-color:#659EC7;
text-decoration:none;
}
#nav li a:focus {
outline-width:0;
}
#nav li a:active + ul.dd, #nav li a:focus + ul.dd, #nav li ul.dd:hover {
left:0;
}
#nav ul.dd li a:active + ul, #nav ul.dd li a:focus + ul, #nav ul.dd li ul:hover {
left:140px;
}
I use this code for highlighting menus. When clicking on submenus, submenu is hidden.
Please help me out.
Thanks,
Shree
For a top menu of my website I am using a css file. The menu works fine for me but I noticed that on smaller screen the menu breaks down, that two or more item of the menu coming down for lack of space. I tried to modified the different parameter of the css but still it did not work. Can anyone please suggest me for the modification of the following css so that the menu works same in different resolution of devices.
CSS
body {
margin:0px;
}
#nav {
background-color:#262626;
width:100%;
height:50px;
box-shadow: 0px 1px 30px #5E5E5E;
position:fixed;
top:0px;
}
#nav > ul {list-style:inside none; padding:0; margin:0;}
#nav > ul > li {list-style:inside none; padding:5px; margin:0; float:left; display:block; position:relative;}
#nav > ul > li > a{ padding: 10px; outline:none; display:block; position:relative; padding:12px 20px; font: 1em/100% Arial, Helvetica, sans-serif; text-align:center; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.4); }
#nav > ul > li > a:after{ content:''; position:absolute; top:-1px; bottom:-1px; right:-2px; z-index:99; }
#nav ul li.has-sub:hover > a:after{top:0; bottom:0;}
#nav > ul > li.has-sub > a:before{ content:''; position:absolute; top:18px; right:6px; border:5px solid transparent; border-top:5px solid #fff; }
#nav > ul > li.has-sub:hover > a:before{top:19px;}
#nav ul li.has-sub:hover > a{ background:#2198bf; border-color:#3f3f3f; padding-bottom:13px; padding-top:13px; top:-1px; z-index:999; }
#nav ul li.has-sub:hover > ul, #cssmenu_top ul li.has-sub:hover > div{display:block;}
#nav ul li.has-sub > a:hover{background:#2198bf; border-color:#3f3f3f;}
#nav ul li > ul, #cssmenu_top ul li > div{ display:none; width:auto; position:absolute; top:38px; padding:10px 0; background:#3f3f3f; border-radius:0 0 5px 5px; z-index:999; }
#nav ul li > ul{width:200px;}
#nav ul li > ul li{display:block; list-style:inside none; padding:0; margin:0; position:relative;}
#nav ul li > ul li a{ outline:none; display:block; position:relative; margin:0; padding:8px 20px; font:10pt Arial, Helvetica, sans-serif; color:#fff; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.5); }
.title {
color:#FF0000;
padding-top: 8px;
font-family:verdana;
font-size:20px;
width:20px;
margin-top:6px;
margin-left:150px;
font-weight:bold;
float:left;
}
.subtitle {
color:#FF0000;
font-family:verdana;
font-size:15px;
}
#navigation{
list-style-type:none;
}
li {
display:inline;
padding:10px;
}
#nav a{
font-family:verdana;
text-decoration:none;
color:#EDEDED;
}
#nav a:hover {
color:#BDBDBD;
}
#body {
width:98%;
margin:0px auto;
margin-top:80px;
font-family:verdana;
}
hr {
border:1px solid #262626;
}
.menu_extended{
position: fixed;
width: 100%;
height: 5px;
top: 48px;
left: 0px;
background-color: #CC0000;
box-shadow: 0px 1px 30px #5E5E5E;
}
In the body of my html page i am writting the following way for creation of menu:
<div id="nav">
<p class="title">
<span style="color:0000FF;"> </span>
</p>
<ul>
<li><a href="index.php" >Home</a></li>
<li>Reading</li>
<li>Multimedia</li>
<li><a href="test_home.php" >Test Yourself</a></li>
<li>Sit for Exam</li>
<li>Analysis</li>
<li>Tips And Tricks</li>
<li>About</li>
</ul>
</div>
Any help ?
Reponsive menu bar can easily be achieved by media queries.If you don't about them then seach it on google.I am providing you a demo url https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries.
In this you have to apply css to your menu bar according to width of device
To make a Responsive menu bar and to target each devices. you can use #media queries.
// normal style
#header-image {
background-repeat: no-repeat;
background-image:url('image.gif');
}
// show a larger image when you're on a big screen
#media screen and (min-width: 1200px) {
#header-image {
background-image:url('large-image.gif');
}
}
// remove header image when printing.
#media print {
#header-image {
display: none;
}
}
Here it is:
http://gyazo.com/e94edf3c9b10bc33c2d9be8ed049583e
As you can see, the submenu works, and when I hover over something on the submenu, it creates a grey background. The problem is, once I get under "Sports Edition", the hover basically cancels and closes the submenu. It stops right where that blue line begins.
Here is the code:
HTML:
<div id="toprightunder">
<ul>
<li>
Content options
<ul>
<li>Default Homepage</li>
<li>News Edition li>
<li>Entertainment Edition</li>
<li>Sports Edition</li>
<li>Latino Edition</li>
</ul>
</li>
</ul>
</div>
CSS: (there is a lot because I was testing a lot)
#toprightunder {
margin-top:18px;
height:15px;
position:absolute;
width:200px;
right:0;
}
#toprightunder a {
text-decoration:none;
color:rgb(100, 100, 100);
margin-left:0;
padding-bottom:3px;
}
#toprightunder ul {
list-style:none;
margin:0 auto;
/*text-align:right;*/
position:relative;
display:inline-table;
margin-left:0;
padding-left:0;
}
#toprightunder ul li {
display:inline;
color:rgb(100, 100, 100);
font-family:"arial", times, sans-serif;
font-size:10px;
margin-top:13px;
text-decoration:none;
margin-left:0;
padding-left:0;
}
#toprightunder ul ul {
display:none;
}
#toprightunder ul li:hover > ul {
display:block;
}
#toprightunder ul ul {
position: absolute;
top: 100%;
padding-top:2px;
padding-bottom:7px;
margin-right:0;
right:0px;
background: white;
border: 1px solid #000;
overflow:hidden;
height:auto;
margin:auto;
}
#toprightunder ul ul li {
position:relative;
color:rgb(100, 100, 100);
font-size:13px;
display:block;
/*margin-bottom:10px;
padding-left:25px;
padding-right:4px;*/
white-space:nowrap;
height:auto;
margin:auto;
}
#toprightunder ul ul li a {
color:#fff;
text-align:left;
float:left;
margin-right:0;
position:relative;
}
#toprightunder a:hover {
background-color:transparent;
color:rgb(100, 100, 100);
}
#toprightunder ul li:hover > li {
background-color:transparent;
}
#toprightunder ul ul li:hover > a {
color:rgb(50, 50, 50);
background:rgb(240, 240, 240);
}
#toprightunder ul ul li > a {
color:rgb(100, 100, 100);
padding-bottom:7px;
padding-top:2px;
padding-left:25px;
width:100%;
}
#headbar a {
text-decoration:none;
color:white;
padding-bottom:2px;
padding-top:4px;
padding-left:8px;
padding-right:8px;
}
#headbar ul ul {
display:none;
}
#headbar ul li:hover > ul {
display:block;
color:green;
}
#headbar ul {
text-decoration:none;
list-style:none;
margin-top:1px;
padding:0;
position:relative;
}
#headbar ul li {
display:inline;
color: white;
padding-bottom:2px;
padding-top:3px;
font-family:"arial", times, sans-serif;
font-size:12px;
}
#headbar ul ul {
border-radius: 0px;
position: absolute;
top: 100%;
padding-top:6px;
}
#headbar ul ul li {
float:none;
position:relative;
color:rgb(100,100,100);
font-size:16px;
}
#headbar ul ul li a {
color:#fff;
}
#headbar ul ul li a:hover {
}
/*#headbar ul:after {
content: "";
clear:both;
display:block;*/
#headbar a:hover {
background-color:rgb(255,255,255);
color:rgb(100,100,100);
}
#headbar ul li:hover > a{
color:rgb(50,50,50);
background-color:transparent;
padding-top:8px;
}
#headbar ul ul li > a {
color:rgb(100,100,100);
padding-top:8px;
}
#headbar {
width: 100%;
height: 20px;
background-color: rgb(30,144,255);
text-decoration:none;
padding-top:129px;
text-align: left;
/*position:relative;*/
}
Add z-index: 2; to the #toprightunder selector and that should resolve your problem.
#toprightunder {
margin-top:18px;
height:15px;
position:absolute;
width:200px;
right:0;
z-index: 2;
}