I was trying to center the menu items in CSS. The bar takes up the whole width of the screen, which is a desired result. I want the menu items to get centered relative to the screen.
Here is the CSS that im using:
#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a {
margin: 0;
padding: 0;
position: relative;
}
#cssmenu {
height: 49px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
border-bottom: 2px solid #0fa1e0;
}
#cssmenu:after,
#cssmenu ul:after {
content: '';
display: block;
clear: both;
}
#cssmenu a {
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
color: #ffffff;
display: inline-block;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 12px;
line-height: 49px;
padding: 0 20px;
text-decoration: none;
}
#cssmenu ul {
list-style: none;
}
#cssmenu > ul {
float: left;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu > ul > li:hover:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #0fa1e0;
margin-left: -10px;
}
#cssmenu > ul > li:first-child > a {
border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
}
#cssmenu > ul > li:last-child > a {
border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
-webkit-border-radius: 0 5px 0 0;
}
#cssmenu > ul > li.active > a {
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
background: #070707;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
}
#cssmenu > ul > li:hover > a {
background: #070707;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
}
#cssmenu .has-sub {
z-index: 1;
}
#cssmenu .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#cssmenu .has-sub ul li {
*margin-bottom: -1px;
}
#cssmenu .has-sub ul li a {
background: #0fa1e0;
border-bottom: 1px dotted #6fc7ec;
filter: none;
font-size: 11px;
display: block;
line-height: 120%;
padding: 10px;
}
#cssmenu .has-sub ul li:hover a {
background: #0c7fb0;
}
#cssmenu .has-sub .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#cssmenu .has-sub .has-sub ul li a {
background: #0c7fb0;
border-bottom: 1px dotted #6db2d0;
}
#cssmenu .has-sub .has-sub ul li a:hover {
background: #095c80;
}
Also, here is the HTML code that im using along with it:
<!DOCTYPE html>
<html lang="en">
<head>
<link href="menu_assets/styles.css" rel="stylesheet" type="text/css">
<link href="<?php echo base_url(); ?>menu_assets/styles.css" rel="stylesheet" type="text/css" />
<div id='cssmenu'>
<ul>
<li class='active'><a href='sample/home'><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Upload Data</span></a>
<ul>
<li class='has-sub'><a href='sample/index'><span>Test Data</span></a>
<ul>
<li><a href='upload_form_att/index'><span>With Attachments</span></a></li>
<li class='last'><a href='sample/index'><span>Without Attachments</span></a></li>
</ul>
</li>
<li class='has-sub'><a href='#'><span>Protocol</span></a>
<ul>
<li><a href='#'><span>With Attachments</span></a></li>
<li class='last'><a href='#'><span>Without Attachments</span></a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'><span>Stability Data table</span></a></li>
<li><a href='#'><span>About</span></a></li>
<li class='last'><a href='#'><span>Logout</span></a></li>
</ul>
</div>
</head>
Any help would be appreciated.
EDIT: After making the changes suggested, I ran into another issue now. When i hove over the "sub menu" item, the "sub-sub menu" item is displayed with a gap and thus making them unclickable. Is there anything else that i need to edit to fix this?
In section should be set - margin-left: 25%;:
#cssmenu ul {
list-style: none;
margin-left: 25%;
}
Independently play around with this value.
In your html code was a mistake:
no tag and the web site body is placed in tag
Your HTML code corrected:
<!DOCTYPE html>
<html lang="en">
<head>
<link href="menu_assets/styles.css" rel="stylesheet" type="text/css">
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id='cssmenu'>
<ul>
<li class='active'><a href='sample/home'><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Upload Data</span></a>
<ul>
<li class='has-sub'><a href='sample/index'><span>Test Data</span></a>
<ul>
<li><a href='upload_form_att/index'><span>With Attachments</span></a></li>
<li class='last'><a href='sample/index'><span>Without Attachments</span></a></li>
</ul>
</li>
<li class='has-sub'><a href='#'><span>Protocol</span></a>
<ul>
<li><a href='#'><span>With Attachments</span></a></li>
<li class='last'><a href='#'><span>Without Attachments</span></a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'><span>Stability Data table</span></a></li>
<li><a href='#'><span>About</span></a></li>
<li class='last'><a href='#'><span>Logout</span></a></li>
</ul>
</div>
</body>
</html>
Add this to CSS file.
#cssmenu{
width:90%; //set according to you
margin:auto;
}
margin:auto automatically centers the element according to page and content width
Related
I'm using Twitter Bootstrap 3 and I have a sidebar and tabs in it.
<div class="col-md-4">
<div class="side-posts">
<ul class="nav nav-tabs nav-justified">
<li class=""><span data-icon=""></span> Recent</li>
<li class="active"><span data-icon=""></span> Popular</li>
</ul>
<div class="tab-content">
.....
</div>
</div>
</div>
When screen's width gets smaller the tabs stack on each other like this
Is it possible to keep the original look and prevent this change?
I had to write my own tabs style to get it work.
Here is a live bootply
in case link got broken here is the css:
/* CSS used here will be applied after bootstrap.css */
body{
background-color: #f2f2f2;
}
.container{
width: 325px;
}
.side-posts{
margin-top:15px;
}
.post-tabs{
padding:0;
margin-bottom:0;
list-style-type: none;
overflow: hidden;
}
.post-tabs li{
display: inline;
}
.post-tabs a{
display: block;
z-index: 1;
text-decoration: none;
padding: 10px 15px;
float: left;
width: 50%;
text-align:center;
border-bottom: 1px solid #dddddd;
text-shadow: 1px 1px 0 white;
transition:color 0.3s ease;
background: rgba(255,255,255,1);
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,1)), color-stop(47%, rgba(246,246,246,1)), color-stop(100%, rgba(237,237,237,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed', GradientType=0 );
color:#3b5998;
}
.post-tabs a:hover{
color:#e95c40;
}
.post-tabs li.active a{
border-bottom: 0;
color: #444444;
z-index: 2;
}
.post-tabs li.active:first-child a {
border-right: 1px solid #dddddd;
box-shadow: inset -3px 0px 3px 0px rgba(0,0,0,0.4);
}
.post-tabs li.active:last-child a{
border-left: 1px solid #dddddd;
box-shadow: inset 3px 0px 3px 0px rgba(0,0,0,0.4);
}
.tab-content{
height:400px;
background-color: #dddddd;
}
You can add float:left; and remove float:none; editing the mobile media query inside bootstrap like:
#media (min-width: 768px){
.nav-tabs.nav-justified > li {
float: none;
}
}
#media (max-width: 768px){
.nav-tabs.nav-justified > li {
float: left;
}
}
DEMO http://jsfiddle.net/a_incarnati/52VtD/7771/
This worked perfectly for me, even keeps the default styling for bootstrap justified nav-bar.**
#media (max-width: 768px){
.nav-justified > li {
display: table-cell;
width: 1%;
}
.nav-justified > li > a {
border-bottom: 1px solid #ddd !important;
border-radius: 4px 4px 0 0 !important;
margin-bottom: 0 !important;
}
.nav-justified > li.active > a {
border-bottom: 1px solid transparent !important;
}
}
I'm trying to make a css3 drop down menu that covers the whole width of my page. I've tried to edit the current code but without any good results.
If I edit the ul,li and set width to 20%, then only the hover button changes to that size. It seems like half of the active button is not showing. I've been fiddling around for a long time now and I'm getting pretty frustrated as all my attempts result in nothing.
Could anyone please help me or give me some advice? It would be very much appreciated so please don't be shy to help a beginner in need!
Have a nice day.
sorry forgot to put the fiddle:
http://jsfiddle.net/dennis2society/hEGut/
HTML:
<div id='cssmenu'>
<ul>
<li class='active'><a href='index.html'>Home</a>
</li>
<li><a href='#'>Training</a>
<ul>
<li><a href='#'>Pupils</a>
</li>
<li><a href='#'>Juniors</a>
</li>
<li><a href='#'>Seniors</a>
</li>
</ul>
</li>
<li><a href='#'>Competition</a>
<ul>
<li><a href='#'>Pupils</a>
</li>
<li><a href='#'>Juniors</a>
</li>
<li><a href='#'>Seniors</a>
</li>
</ul>
</li>
<li><a href='#'>About Us</a>
</li>
<li><a href='#'>Contact</a>
</li>
</ul>
</div>
CSS:
#cssmenu ul, #cssmenu li, #cssmenu span, #cssmenu a {
margin: 0;
padding: 0;
position: relative;
}
#cssmenu:after, #cssmenu ul:after {
content:'';
display: block;
clear: both;
}
#cssmenu a {
color: #ffffff;
display: inline-block;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 12px;
min-width: 35px;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 0 #333333;
}
#cssmenu ul {
list-style: none;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu > ul > li.active a {
background: #646464 url(images/grad_dark.png) repeat-x left bottom;
background: -moz-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #646464), color-stop(100%, #4a4a4a));
background: -webkit-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -o-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -ms-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: linear-gradient(to bottom, #646464 0%, #4a4a4a 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#646464', endColorstr='#4a4a4a', GradientType=0);
box-shadow: inset 0 0 10px #222222, inset 0 10px 10px #222222;
-moz-box-shadow: inset 0 0 10px #222222, inset 0 10px 10px #222222;
-webkit-box-shadow: inset 0 0 10px #222222, inset 0 10px 10px #222222;
filter: none;
}
#cssmenu > ul > li.active a:hover {
background: -moz-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #646464), color-stop(100%, #4a4a4a));
background: -webkit-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -o-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -ms-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: linear-gradient(to bottom, #646464 0%, #4a4a4a 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#646464', endColorstr='#4a4a4a', GradientType=0);
filter: none;
}
#cssmenu > ul > li a {
box-shadow: inset 0 0 0 1px #8a8a8a;
-moz-box-shadow: inset 0 0 0 1px #8a8a8a;
-webkit-box-shadow: inset 0 0 0 1px #8a8a8a;
background: #4a4a4a url(images/grad_dark.png) repeat-x left top;
background: -moz-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #8a8a8a), color-stop(50%, #707070), color-stop(51%, #626262), color-stop(100%, #787878));
background: -webkit-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: -o-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: -ms-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: linear-gradient(to bottom, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#8a8a8a', endColorstr='#787878', GradientType=0);
border-bottom: 1px solid #5d5d5d;
border-top: 1px solid #5d5d5d;
border-right: 1px solid #5d5d5d;
line-height: 34px;
padding: 0 35px;
filter: none;
}
#cssmenu > ul > li a:hover {
background: #8a8a8a url(images/grad_dark.png) repeat-x left bottom;
background: -moz-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #646464), color-stop(50%, #4a4a4a), color-stop(51%, #3b3b3b), color-stop(100%, #525252));
background: -webkit-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: -o-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: -ms-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: linear-gradient(to bottom, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#8a8a8a', endColorstr='#787878', GradientType=0);
filter: none;
}
#cssmenu > ul > li:first-child a {
border-left: 1px solid #5d5d5d;
}
#cssmenu > ul > li:last-child a {
}
#cssmenu li:hover ul {
display: block;
}
#cssmenu li ul {
display: none;
position: absolute;
top: 36px;
left: -1px;
min-width: 100%;
text-align: center;
/* IE7 */
*width: 100%;
}
#cssmenu li ul li {
text-align: center;
}
#cssmenu li ul li a {
border-top: 0 none;
border-left: 1px solid #5d5d5d;
display: block;
line-height: 120%;
padding: 9px 5px;
text-align: center;
}
You were almost there, all you need is a width declaration on the first level li and a display:block and their child anchor elements:
#cssmenu > ul > li {
/* width here:*/
float: left;width:20%;
}
#cssmenu > ul > li a {
display:block;
/* the other stuff*/
}
Your modified fiddle
p.s. nice design! However, you should check it with several different browsers, there is some difference between Chome and Firefox/IE.
i have created a css3 style sheet for creating menu, in submenu of main menu is correct but after creating submenu. The child element of the submenu does not work correctly.
i want to move submenu's submenu to bottom of parent and i can move mouse cursor on child
JSFIDDLE
HTML:
<ul id="nav" class="nav" style='margin-right:0px;padding-right:0px;padding-top:0px;height:30px;'>
<li><a>MAIN MENU</a>
<ul>
<li>MENU 1
<ul>
<li><a>SUBMENU</a></li>
</ul>
</li>
<li>MENU 2</li>
<li>MENU 3</li>
</ul>
</li>
</ul>
CSS3:
#nav {
color: #fff;
margin: 0;
line-height: 100%;
padding-top: 4px;
padding-bottom: 4px;
height: 33px;
background: -moz-linear-gradient(center top , #5E9AE2, #3570B8) repeat scroll 0 0 transparent;
z-index: 10000;
}
#nav li {
margin: 0pt 5px;
padding: 2pt 0pt 5px;
float: right;
position: relative;
list-style: none outside none;
z-index: 10000;
cursor: pointer;
}
#nav a {
color: #fff !important;
text-decoration: none;
display: block;
padding: 9px 10px;
margin-right: 0pt;
border-radius: 5px 5px 5px 5px;
font-weight: normal;
z-index: 100000;
cursor: pointer;
}
#nav .current a, #nav li:hover > a {
z-index: 100000;
background: #fff ! important;
color: #000 ! important;
box-shadow: 0pt 1px 1px rgba(0, 0, 0, 0.2);
}
#nav ul li:hover a, #nav li:hover li a {
z-index: 100000;
background: none repeat scroll 0% 0% transparent;
color: #000 ! important;
box-shadow: none;
}
#nav ul a:hover {
background: -moz-linear-gradient(center top , rgb(198, 71, 53), rgb(147, 35, 19)) repeat scroll 0% 0% transparent ! important;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c44634), color-stop(100%,#952414)) repeat scroll 0% 0% transparent ! important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* Opera 11.10+ */
background: -ms-linear-gradient(top, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* IE10+ */
background: linear-gradient(to bottom, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c44634', endColorstr='#952414',GradientType=0 ) ! important; /* IE6-9 */
color: rgb(255, 255, 255) ! important;
border-radius: 0pt 0pt 0pt 0pt;
text-shadow: 0pt 1px 1px rgba(0, 0, 0, 0.1);
cursor: pointer;
}
#nav ul {
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #cfcfcf 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#cfcfcf)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#cfcfcf 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#cfcfcf 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#cfcfcf 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#cfcfcf 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#cfcfcf',GradientType=0 ); /* IE6-9 */
display: none;
margin: 0pt;
padding: 0pt;
text-align: right;
width: 180px;/*طول منو*/
position: absolute;
top: 35px;
right: 0pt;
border-radius: 5px 5px 5px 5px;
direction: rtl;
box-shadow: 0pt 1px 3px rgba(0, 0, 0, 0.3);
}
#nav li:hover > ul {
display: block;
}
#nav ul li {
float: none;
margin: 0pt;
padding: 0pt;
}
#nav ul li ul{
float: none;
margin-top:28px;
margin-right: 180px;
top: 0px;
}
#nav ul li ul li:first-child > a {
border-radius: 5px 5px 5px 5px;
behavior: url('./css/PIE.htc');
}
#nav ul li ul li:last-child > a {
border-radius: 5px 5px 5px 5px;
behavior: url('./css/PIE.htc');
}
#nav ul a {
font-weight: normal;
text-shadow: 0pt 1px 1px rgba(255, 255, 255, 0.898);
}
#nav ul li:first-child > a {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-radius: 5px 5px 0px 0px;
behavior: url('./css/PIE.htc');
}
#nav ul li:last-child > a {
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-radius: 0px 0px 5px 5px;
behavior: url('./css/PIE.htc');
}
#nav:after {
z-index: 100000;
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0pt;
height: 0pt;
}
this method not problem but i want to have any submenu and cant fix it.please help me,
#nav ul li ul {
float: none;
margin-right: 180px;
margin-top: 28px; /* <-- this is causing issue */
top: 0;
}
i don't know where the problem every thing work just remove margin-top
and add the html
<ul id="nav" class="nav" style='margin-right:0px;padding-right:0px;padding-top:0px;height:30px;'>
<li><a>MAIN MENU</a>
<ul>
<li>MENU 1
<ul>
<li><a>SUBMENU</a>
<ul>
<li><a>asdasd</a></li>
<li><a>asdasd</a></li>
<li><a>asdasd</a></li>
</ul>
</li>
</ul>
</li>
<li>MENU 2</li>
<li>MENU 3</li>
</ul>
</li>
see demo : jsfiddle
I found a nice menu toolbar but i want it on the website at the right like example 2
the link to the toolbar is this http://cssmenumaker.com/menu/red-opera-drop-down-menu
and the other toolbar example menu is this website http://www.fluidbyte.net/workshop/responsive_nav/index.html
so the what should i change in the CSS file to have it at the right corner of my website?
the code to the css file is here:
#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a {
margin: 0;
padding: 0;
position: relative;
}
#cssmenu {
height: 49px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
border-bottom: 2px solid #e00f16;
}
#cssmenu:after,
#cssmenu ul:after {
content: '';
display: block;
clear: both;
}
#cssmenu a {
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
color: #ffffff;
display: inline-block;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 12px;
line-height: 49px;
padding: 0 20px;
text-decoration: none;
}
#cssmenu ul {
list-style: none;
}
#cssmenu > ul {
float: left;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu > ul > li:hover:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #e00f16;
margin-left: -10px;
}
#cssmenu > ul > li:first-child > a {
border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
}
#cssmenu > ul > li:last-child > a {
border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
-webkit-border-radius: 0 5px 0 0;
}
#cssmenu > ul > li.active > a {
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
background: #070707;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
}
#cssmenu > ul > li:hover > a {
background: #070707;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
}
#cssmenu .has-sub {
z-index: 1;
}
#cssmenu .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#cssmenu .has-sub ul li {
*margin-bottom: -1px;
}
#cssmenu .has-sub ul li a {
background: #e00f16;
border-bottom: 1px dotted #ec6f73;
filter: none;
font-size: 11px;
display: block;
line-height: 120%;
padding: 10px;
}
#cssmenu .has-sub ul li:hover a {
background: #b00c11;
}
#cssmenu .has-sub .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#cssmenu .has-sub .has-sub ul li a {
background: #b00c11;
border-bottom: 1px dotted #d06d70;
}
#cssmenu .has-sub .has-sub ul li a:hover {
background: #80090d;
}
It is hard to tell without the HTML to see what your CSS is referencing, but you can try applying
float: right;
to #cssmenu.
Get some web development tools. You can see the code clear as day if you fire up Firefox and hit F12.
nav {
display: block;
float: right;
margin: -15px -12px 0 0;
}
It's the float:right; part that does it.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How do i solve this, i tried editing in many places, but i don't understand the trick part.
This is the url:http://www.pineappletimes.com/
This is the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pineappletimes.com</title>
<style type="text/css">#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a
{
margin: 0;
padding: 0;
position: relative;
}
#cssmenu:after,
#cssmenu ul:after
{
content: '';
display: block;
clear: both;
}
#cssmenu a
{
color: #ffffff;
display: inline-block;
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif;
font-size: 14px;
min-width: 120px;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 0 #333333;
}
#cssmenu ul
{
list-style: none;
}
#cssmenu > ul > li
{
float: left;
}
#cssmenu > ul > li.active a
{
background: #646464 url(http://www.pineappletimes.com/images/grad_dark.png) repeat-x left bottom;
background: -moz-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #646464), color-stop(100%, #4a4a4a));
background: -webkit-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -o-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -ms-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: linear-gradient(to bottom, #646464 0%, #4a4a4a 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#646464', endColorstr='#4a4a4a', GradientType=0);
box-shadow: inset 0 0 10px #222222, inset 0 10px 10px #222222;
-moz-box-shadow: inset 0 0 10px #222222, inset 0 10px 10px #222222;
-webkit-box-shadow: inset 0 0 10px #222222, inset 0 10px 10px #222222;
filter: none;
}
#cssmenu > ul > li.active a:hover
{
background: -moz-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #646464), color-stop(100%, #4a4a4a));
background: -webkit-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -o-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: -ms-linear-gradient(top, #646464 0%, #4a4a4a 100%);
background: linear-gradient(to bottom, #646464 0%, #4a4a4a 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#646464', endColorstr='#4a4a4a', GradientType=0);
filter: none;
}
#cssmenu > ul > li a
{
box-shadow: inset 0 0 0 1px #8a8a8a;
-moz-box-shadow: inset 0 0 0 1px #8a8a8a;
-webkit-box-shadow: inset 0 0 0 1px #8a8a8a;
background: #4a4a4a url(http://www.pineappletimes.com/images/grad_dark.png) repeat-x left top;
background: -moz-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #8a8a8a), color-stop(50%, #707070), color-stop(51%, #626262), color-stop(100%, #787878));
background: -webkit-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: -o-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: -ms-linear-gradient(top, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
background: linear-gradient(to bottom, #8a8a8a 0%, #707070 50%, #626262 51%, #787878 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#8a8a8a', endColorstr='#787878', GradientType=0);
border-bottom: 1px solid #5d5d5d;
border-top: 1px solid #5d5d5d;
border-right: 1px solid #5d5d5d;
line-height: 34px;
padding: 0 35px;
filter: none;
}
#cssmenu > ul > li a:hover
{
background: #8a8a8a url(http://www.pineappletimes.com/images/grad_dark.png) repeat-x left bottom;
background: -moz-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #646464), color-stop(50%, #4a4a4a), color-stop(51%, #3b3b3b), color-stop(100%, #525252));
background: -webkit-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: -o-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: -ms-linear-gradient(top, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
background: linear-gradient(to bottom, #646464 0%, #4a4a4a 50%, #3b3b3b 51%, #525252 100%);
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#8a8a8a', endColorstr='#787878', GradientType=0);
filter: none;
}
#cssmenu > ul > li:first-child a
{
border-radius: 5px 0 0 5px;
-moz-border-radius: 5px 0 0 5px;
-webkit-border-radius: 5px 0 0 5px;
border-left: 1px solid #5d5d5d;
}
#cssmenu > ul > li:last-child a
{
border-radius: 0 5px 5px 0;
-moz-border-radius: 0 5px 5px 0;
-webkit-border-radius: 0 5px 5px 0;
}
#cssmenu .has-sub:hover ul
{
display: block;
}
#cssmenu .has-sub ul
{
display: none;
position: absolute;
top: 36px;
left: -1px;
min-width: 100%;
text-align: center;
/* IE7 */
*width: 100%;
}
#cssmenu .has-sub ul li
{
text-align: center;
}
#cssmenu .has-sub ul li a
{
border-top: 0 none;
border-left: 1px solid #5d5d5d;
display: block;
line-height: 120%;
padding: 9px 5px;
text-align: center;
}
#cssmenu
{
margin-top:10%;
margin-left:15%;
width:80%;
}
#mainarticle {
position:absolute;
width:58%;
height:50%;
border:#F7F7F7;
border-width:20px;
border-style:solid;
z-index:1;
top:28%;
left:12%;
font-size:100%;
padding:1%;
font-family: "Open Sans";
}
#twitterfeed {
position:absolute;
margin-left:76%;
top:27%;
width:22%;
height:70%;
}
#logo
{
position:absolute;
width:100%;
height:17%;
z-index:1;
top:0%;
background-repeat: no-repeat;
background-color:#000;
color:#FFF;
font-family: "tabs";
}
#font-face {
font-family: "Open Sans bold";
src: url(http://www.pineappletimes.com/Fonts/OpenSans-Bold.ttf) format("truetype");
}
#font-face {
font-family: "Open Sans";
src: url(http://www.pineappletimes.com/Fonts/OpenSans-Regular.ttf) format("truetype");
}
#font-face {
font-family: "tabs";
src: url(http://www.pineappletimes.com/Fonts/tabs.ttf) format("truetype");
}
</style>
</head>
<body style="margin:0px;padding:0px;">
<div id="logo">
<a href="http://www.pineappletimes.com/" >
<img src="http://www.pineappletimes.com/images/logo.png" />
</a>
</div>
<div id='cssmenu'>
<ul>
<li class='active '><a href='cssmenu/index.html'><span>Articles</span></a></li>
<li><a href='#'><span>Howlah Index</span></a></li>
<li class='has-sub '><a href='#'><span>Humorous Horoscope</span></a>
<ul>
<li><a href='#'><span>Aries</span></a></li>
<li><a href='#'><span>Taurus</span></a></li>
<li><a href='#'><span>Gemini</span></a></li>
<li><a href='#'><span>Cancer</span></a></li>
<li><a href='#'><span>Leo</span></a></li>
<li><a href='#'><span>Virgo</span></a></li>
<li><a href='#'><span>Libra</span></a></li>
<li><a href='#'><span>Scorpio</span></a></li>
<li><a href='#'><span>Sagittarius </span></a></li>
<li><a href='#'><span>Capricorn</span></a></li>
<li><a href='#'><span>Aquarius</span></a></li>
<li><a href='#'><span>Pisces</span></a></li>
</ul>
</li>
<li><a href='#'><span>Agony Aunt</span></a></li>
</ul>
</div>
<div id="mainarticle"><img src="http://www.pineappletimes.com/images/arvindmosquito.png" width="300" height="100" alt="kejriwalmosq" align="left" style="margin-right:2%"/><p style="font-family: Open Sans bold;"> Dengue cases rise in Delhi; Arvind Kejriwal wants probe against mosquitoes</p><br> After Robert Vadra and Nitin Gadkari, Mr. Kejriwal has now targeted the Mosquitoes for causing dengue fever in Delhi and other parts of the country. He wants the actions of mosquitoes to be probed using all the government machinery available. Association of mosquitoes (ASS_MO) has clearly denied any wrongdoing and has issued a statement supporting its members’ actions.<br>
The statement reads...<br><br>
“We have no intention to harm humans. Some of our members who love humans more than others got over excited and kissed a few people. What happened after that is not our responsibility. We have acted as per law and not kissed any person in public.“
<a href="http://www.pineappletimes.com/kejriwal_mosquito.html" > Read more</a>
</div>
<div id="twitterfeed">
<a class="twitter-timeline" href="https://twitter.com/PineappleTimes" data-widget-id="274533936351289345">Tweets by #PineappleTimes</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
</body>
</html>
#cssmenu .has-sub ul {
z-index: 1000;
}