Adding arrow to existing menu - css

Here is my css code where i want to add arrow-down.gif for the menu have child items.
Css : MyCSSMenu Core CSS [Do Not Modify!]
.qmmc .qmdivider {
display:block;
font-size:1px;
border-width:0px;
border-style:solid;
position:relative;
z-index:1;
}
.qmmc .qmdividery {
float:left;
width:0px;
}
.qmmc .qmtitle {
display:block;
cursor:default;
white-space:nowrap;
position:relative;
z-index:1;
}
.qmclear {
font-size:1px;
height:0px;
width:0px;
clear:left;
line-height:0px;
display:block;
float:none !important;
}
.qmmc {
position:relative;
zoom:1;
z-index:10;
}
.qmmc a, .qmmc li {
float:left;
display:block;
white-space:nowrap;
position:relative;
z-index:1;
}
.qmmc div a, .qmmc ul a, .qmmc ul li {
float:none;
}
.qmsh div a {
float:left;
}
.qmmc div {
visibility:hidden;
position:absolute;
}
.qmmc li {
z-index:auto;
}
.qmmc ul {
left:-10000px;
position:absolute;
z-index:10;
}
.qmmc, .qmmc ul {
list-style:none;
padding:0px;
margin:0px;
}
.qmmc li a {
float:none
}
.qmmc li:hover>ul {
left:auto;
}
#qm0 ul {
top:100%;
}
#qm0 ul li:hover>ul {
top:0px;
left:100%;
}
#qm0 a {
padding:5px 4px 5px 5px;
color:#7a7a7a;
/*font-family:Arial;*/
font-size:14px;
font-weight:bold;
text-decoration:none;
background:url(../images/nav-bg.gif) left top repeat-x;
height:30px;
line-height:33px;
}
#qm0 div, #qm0 ul {
padding:2px;
margin:-2px 0px 0px;
background-color:#f7f7f7;
border-width:1px;
border-style:solid;
border-color:#7a7a7a;
}
#qm0 div a, #qm0 ul a {
padding:3px 10px 3px 5px;
background-color:#7a7a7a;
font-size:14px;
border-width:0px;
border-style:none;
height:20px;
line-height:23px;
background:url(../images/nav-bg.gif) left top repeat-y;
color:#7a7a7a;
}
#qm0 div a:hover, #qm0 ul a:hover {
background-color:#cdcdcd;
color:#7a7a7a;
}
body #qm0 div .qmactive, body #qm0 div .qmactive:hover {
background-color:#7a7a7a;
color:#cc0000;
font-weight:bold;
}
#qm0 .qmtitle {
cursor:default;
padding:3px 0px 3px 4px;
color:#7a7a7a;
/*font-family:arial;*/
font-size:14px;
font-weight:bold;
}
#qm0 .qmdividerx {
border-top-width:1px;
margin:4px 0px;
border-color:#bfbfbf;
}
#qm0 .qmdividery {
border-left-width:1px;
height:15px;
margin:4px 2px 0px;
border-color:#555;
}
#qm0 .qmritem span {
border-color:#dadada;
background-color:#f7f7f7;
}
#qm0 .qmritemcontent {
padding:0px 0px 0px 4px;
}
html :
<ul id="qm0" class="qmmc">
<li>Home
</li>// no arrow here
<li><a class="qmparent" href="#" title="News">News</a> //here the arrow should appear
<ul>
<li>Coastal News
</li>
<li>State News
</li>
<li>National News
</li>
</ul>
</li>
<li><a class="qmparent" href="#" title="Features">Features</a> //here the arrow should appear
<ul>
<li>Editorial
</li>
<li>Special Report
</li>
</ul>
</li>
The code is taken from mycssmenu

EDIT: To show the arrows not only on hover, remove the :hover-pseudo class. I updated the fiddles, too.
Pure CSS way
You can solve this with CSS only using the border property like this (fiddle):
.qmmc > li {
margin-right: 12px;
}
.qmmc > li.has-sub:after {
display: block;
position: absolute;
content: '';
width: 0;
height: 0;
top: 50%;
right: -12px;
border-style: solid;
border-width: 6px 6px 0 6px;
border-color: #000 transparent transparent transparent;
}
Using Background image
You can add the image like this (fiddle)
.qmmc > li {
margin-right: 12px;
}
.qmmc > li.has-sub:after {
display: block;
position: absolute;
content: '';
width: 12px;
height: 100%;
top: 0%;
right: -12px;
background: url(PATH/TO/IMAGE/arrow-down.gif) no-repeat center center;
background-size: contain;
}
Using CSS only would be the cleaner, more modern approach.

An elegant CSS only solution will be to use pseudo elements.
Adding this to your CSS will do exactly what you want:
.qmmc li > a:after {
margin-left: 4px;
content: url(link/to/right-arrow.png);
} /* This will be used when you have sub-sub-menus*/
.qmmc > li > a:after {
margin-left: 4px;
content: url(link/to/down-arrow.png);
} /* This will be used when you have sub-menus*/
.qmmc li > a:only-child:after {
margin-left: 0;
content: '';
} /* This will be used when you have no sub-menus*/
You can change the content to '\25BA' and '\25BC' in 1st and 2nd definitions respectively to get nice arrows without using images. See a DEMO here, see that I have added a further sub-menu to "Costal News" sub-menu item for demonstration.

Related

How to overlap a border in CSS in order to create tabs?

I'm trying to create the following tabs:
And have a problem figuring out how to make the active tab overlap the order on the list. Here is the HTML:
<ul>
<li class="active">LATEST</li>
<li>VOTES</li>
<ul>
Without div:
Demo: http://jsfiddle.net/GCu2D/790/
CSS:
html, body {
margin:0;
padding:0;
height:100%;
width:100%;
background-color:#f0f0f0
}
ul {
margin:0px;
padding:0;
position:relative;
}
ul:before {
left: 0;
right: 0;
bottom: 0px;
height: 0;
border-bottom: 1px solid #777;
content:"";
top: auto;
display: block;
position: absolute;
}
ul:after {
clear:both;
display:block;
content:""
}
ul li {
display:block;
float:left;
padding:5px 10px;
border:1px solid #777;
margin-right:-1px;
position:relative;
}
ul li.active {
border-bottom:1px solid #f0f0f0
}
HTML:
<ul>
<li class="active">LATEST</li>
<li>VOTES</li>
</ul>
With extra div
You can try this way: http://jsfiddle.net/GCu2D/787/
CSS:
html, body {
margin:0;
padding:0;
height:100%;
width:100%;
background-color:#f0f0f0
}
ul {
margin:0px;
padding:0;
}
ul:after {
clear:both;
display:block;
content:""
}
ul li {
display:block;
float:left;
padding:5px 10px;
border:1px solid #777;
margin-right:-1px;
position:relative;
}
div {
border:1px solid #777;
margin-top:-1px;
}
ul li.active {
border-bottom:1px solid #f0f0f0
}
HTML:
<ul>
<li class="active">LATEST</li>
<li>VOTES</li>
</ul>
<div>Content</div>
Why don't you hide the bottom border of the active link instead?
.active{
border-bottom: 0;
}
Or make it transparent:
.active{
border-bottom: 1px solid transparent;
}

Navigation menu hides position

I can't figure out what is going on here, perhaps it's just too early!!
See this FIDDLE
When clicking on the links below the grey box, it will eventually scroll the relative content from right to left etc. However, when clicking items 2 & 3 in the nav, transport or scholarships, the navigation menu seems to move to the left or disappears completely! If someone could cast an eye, and correct my stupidity it'd be gratefully appreciated!
HTML:
<div class="finance-galleryWrapper">
<div class="galleryView">
<div class="swapView">
<li class="gallery-item" id="Fees"></li>
<li class="gallery-item" id="Transport"></li>
<li class="gallery-item" id="Scholarships"></li>
</div>
<nav class="toggle-nav">
<ul>
<li>Fees</li>
<li>Transport</li>
<li>Scholarships</li>
</ul>
</nav>
</div>
</div>
CSS:
/* --- Galleries --- */
.finance-galleryWrapper {
width: 860px;
height: 559px;
margin: 0 40px;
overflow: scroll;
}
.galleryView {
width: 860px;
overflow: hidden;
display: block;
}
.swapView {
width: 2580px;
height: 427px;
background: #666;
overflow: scroll;
}
li.gallery-item {
width: 860px;
height: 427px;
display: inline;
float: left;
}
/* toggle-nav */
/* toggle-nav */
.toggle-nav {
width:720px;
margin:50px auto 30px;
text-align:center;
position:relative;
z-index:1001;
}
.toggle-nav ul {
margin:0 auto;
}
.toggle-nav li, .toggle-nav li a {
display:-moz-table-cell;
display:inline-block;
*display:inline;
*zoom:1;
}
.toggle-nav li {
width:168px;
}
.toggle-nav li a {
width:171px;
margin:0 auto;
padding:6px 0 7px;
border:1px solid #cfcfcf;
font-family:Open Sans;
font-size:16px;
color:#666;
text-align:center;
text-decoration:none;
background-color:#fff;
}
.toggle-nav li a:hover {
color:#08c;
}
.toggle-nav li a:first-child {
border-left:1px solid #cfcfcf;
}
.toggle-nav li:first-child a {
border-radius:6px 0 0 6px;
box-shadow:none;
}
.toggle-nav li:last-child a {
border-radius:0 6px 6px 0;
}
.toggle-nav li a.active {
position:relative;
cursor:default;
text-decoration:none;
border:1px solid #2284d1;
color:#fff;
background-color:#59b1f6;
}
There you go it works now, however themenu looks different as I was working on it. Change it back again. Your code was very messy and was calling the same ids and classes so many times , i bet your html page was confused as hell and ya like the guy below said that you forgot to put proper position types. Your main one should have had position:absolute. You also missed out on proper display types like display:block
/* --- Galleries --- */
.finance-galleryWrapper {
width: 860px;
height: 559px;
margin: 0 40px;
overflow: scroll;
}
.galleryView {
width: 860px;
overflow: hidden;
display: block;
}
.swapView {
width: 2580px;
height: 427px;
background: #666;
overflow: scroll;
}
li.gallery-item {
width: 860px;
height: 427px;
display: inline;
float: left;
}
/* toggle-nav */
/* toggle-nav */
.toggle-nav {
width:720px;
margin:50px auto 30px;
text-align:center;
position:relative;
z-index:999;
display:block;
position:absolute;
}
.toggle-nav ul {
margin:auto;
display:block;
position:relative;
padding:0px;
}
.toggle-nav li {
display:inline-block;
position:relative;
margin:0px auto;
padding:0px;
}
.toggle-nav a {
width:171px;
margin:0 auto;
padding:6px 0 7px;
border:1px solid #cfcfcf;
font-family:Open Sans;
font-size:16px;
color:#666;
text-align:center;
text-decoration:none;
background-color:#fff;
}
.toggle-nav li a:hover {
color:#08c;
}
.toggle-nav li a:first-child {
border-left:1px solid #cfcfcf;
}
.toggle-nav li:first-child a {
border-radius:6px 0 0 6px;
box-shadow:none;
}
.toggle-nav li:last-child a {
border-radius:0 6px 6px 0;
}
.toggle-nav li a.active {
position:relative;
text-decoration:none;
border:1px solid #2284d1;
color:#fff;
background-color:#59b1f6;
}

CSS horizontal menu with variable width from parent div

I'm trying to create a horizontal menu with the width of the parent div and where the links are arranged in equal distances. Target is to create a navigation bar with a width of 900px. Maybe it is possible to realize it on another way? I'm a newbie in css and don't know how to fix my problem and hope you could help me!
#nav {
background:red;
width:900px;
}
ul#nav-bar, ul#nav-bar ul{
margin:0;
list-style:none;
padding:0;
background: white;
border: 1px solid black;
}
ul#nav-bar ul{
display:none;
position:absolute;
left:0;
}
ul#nav-bar li:hover>*{
display:block;
}
ul#nav-bar li{
position:relative;
display:block;
white-space:nowrap;
font-size:0;
float:left;
}
ul#nav-bar li:hover{
z-index:1;
}
ul#nav-bar{
font-size:0;
z-index:999;
position:relative;
display:inline-block;
zoom:1;
padding:0;
*display:inline;
}
* html ul#nav-bar li a{
display:inline-block;
}
ul#nav-bar>li{
margin:0;
}
ul#nav-bar a:active, ul#nav-bar a:focus{
outline-style:none;
}
ul#nav-bar a{
display:block;
vertical-align:middle;
text-align:center;
text-decoration:none;
font: 12px Arial;
color:#000000;
padding:5px 10px 5px 10px;
}
ul#nav-bar ul li{
float:none;
margin:0 0 0;
}
ul#nav-bar ul a{
text-align:left;
background-color:red;
color:#000;
}
ul#nav-bar li:hover>a{
background-color:#fff;
color:#000000;
}
ul#nav-bar span{
display:block;
overflow:visible;
background-position:right center;
background-repeat:no-repeat;
padding-right:0px;
}
<div id="nav">
<ul id="nav-bar">
<li>Link1</li>
<li><span>Link2</span>
<ul>
<li>lowerLink1</li>
<li>lowerLink2</li>
<li>lowerLink3</li>
</ul>
</li>
<li>Link3</li>
<li><span>longxxxxxxxxxxxxxxxxxxxxxxxxxxxlink</span>
<ul>
<li>lowerLink1</li>
<li>lowerLink2</li>
<li>lowerLink3</li>
</ul>
</li>
<li>Link5</li>
<li>Link6</li>
<li>longxxxxxxxxxxxxxlink</li>
</ul>
</div>
Thanks!
To get the #nav-bar to match the parent, simply add width:100% to your existing ul#nav-bar tag in css. This tells your child to fill up the parent, regardless of child's content.
As for spreading out the links, it has been my experience that the best way to do this is to add margins to the text once the navbar is complete. For your coded example, I would add the following to even them out:
ul#nav-bar->li{
margin:0px 20px 0px 20px;
text-align:center;
}
You can view it here and here is the css code
/*zero-height container problem fix for floated elements*/
.clearfix:before,
.clearfix:after {
content:"";
display:table;
}
.clearfix:after {
clear:both;
}
#nav {
background:#999;
width:900px;
}
#nav ul{
list-style: none;
padding: 0;
margin: 0;
}
#nav li{
position: relative;
text-align: center;
padding: 10px 0px;
}
#nav a{
text-decoration: none;
display: block;
color: #f0f0f0;
}
#nav-bar > li{
float: left;
}
#nav-bar ul{
position: absolute;
left: 0;
width: 100%;
top: 100%;
background: #999;
display: none;
}
#nav-bar li:hover{
background: #666;
}
#nav-bar li:hover ul{
display: block;
}
As if you want width to be adjusted to text width in li elements so you need javascript
and here is the code i have updated the jsfiddle
$(document).ready(function(){
total_nav_width = $('#nav').width();
main_link = $('#nav-bar > li > a')
textWidths = [];
totalTextWidth = 0;
main_link.each(function(){
textWidths.push($(this).width())
})
for (var i = 0; i < textWidths.length; i++) {
totalTextWidth += textWidths[i];
}
additionValues = (total_nav_width - totalTextWidth)/main_link.length;
main_link).each(function(){
intialWidth = $(this).width()
$(this).width( intialWidth + additionValues )
})
})

Css Transition For My Home Made Nav

I have created a nav menu myself for my website, I'm no expert but I think the menu turned out great ... I would like for my the menus to open a little slower then instant, maybe have a .5s transition ... I have tried to implement myself but I just don't seem to be able to figure it out .... I have created a jsfiddle to show my nav bar ... I was hoping to someone could show me how to had a transition to all the drop down menus if its possible ... Thank You
jsfiddle : http://jsfiddle.net/vRdEp/ (its a little broken on here)
my site : www.curious-howto.com
My css:
ul#navitemul {
border-radius: 0px 20px 20px 20px;
margin:0px!important;
width:500px;
}
.belownav {
top:0px;
left:183px;
position:absolute;
z-index:100;
box-shadow: 0 0 10px #000 inset;
border-radius: 5px 0px 0px 5px;
padding:20px!important;
background:#282828!important;
}
.navitem a {
margin-right: 10px;
border: 1px solid #424242!important;
text-overflow:ellipsis;
display:block;
overflow:hidden;
border-radius:5px;
width:200px!important;
padding:0px!important;
float:left;
height:40px;
background:#424242!important;
}
.navitem a:hover {
border:1px solid #585858!important;
background:#000!important;
}
img.fl {
float:left;
}
span.marleft {
letter-spacing:1px;
font-size:12px!important;
text-decoration:none;
color:white!important;
margin-left:15px!important;
line-height:38px;
}
li.marright{
float:left!important;
margin-bottom:10px!important;
margin-right:10px!important;
}
.ontop{
color:white;
font-size:28px!important;
margin-bottom:20px!important
}
ul#loginmenu {
border-radius:0px 0px 30px 30px;
z-index:1000;
left:200px;
width:500px!important;
overflow:auto;
max-height:600px;
left:-100px!important;
}
li.logo {
margin:0px!important;
line-height:10px!important;
border-radius: 30px 0px 0px 0px;
padding:10px 40px 10px 40px!important
}
span#navlogo {
font-size:20px;
}
#menu{
position:relative;
top:10px;
width:80%;
max-width:750px;
min-width:660px;
height:47px;
border-radius: 30px 30px 0px 0px;
background-color:#172322;
margin:0px;
padding:0px;
list-style:none;
color:#fff;
display:inline-block;
float:right;
z-index:1000;
}
#menu a {
color:#fff;
text-decoration:none;
}
#menu > li {
transition:width 2s, height 2s;
-webkit-transition:width 2s, height 2s, -webkit-transform 2s;
/* Safari */padding: 13px 0px;
background:#172322 none repeat scroll 0 0;
cursor:pointer;
float:left;
position:relative;
}
#menu > li a:hover {
color:#B0D730;
}
#menu .logo {
background-color: #7cb7e3;
width:87px;
padding:0px;
}
/* sub-menus*/
#menu ul {
padding:0px;
margin:0px;
display:block;
display:inline;
}
#menu li ul {
position:absolute;
left:-24px;
top:0px;
margin-top:45px;
line-height:16px;
background-color:#172322;
color:#0395CC;
/* for IE */ display:none;
}
#menu li:hover ul {
display:block;
}
#menu li ul li{
display:block;
margin:5px 20px;
padding: 5px 0px;
list-style-type:none;
}
#menu li ul li:first-child {
border-top: none;
}
#menu li ul li a {
display:block;
color:#0395CC;
}
#menu li ul li a:hover {
color:#7FCDFE;
}
/* main submenu */
#menu #main li {
text-align:center;
margin:10px 10px 10px 10px!important
}
#menu #main {
border-radius: 0px 0px 30px 30px;
width:167px;
left:0px;
top:-20px;
padding-top:20px;
background-color:#7cb7e3;
color:#fff;
z-index:999;
}
/* search */
.searchContainer div {
background-color:#fff;
display:inline;
padding:5px;
}
.searchContainer input[type="text"] {
border:none;
}
.searchContainer ul {
vertical-align:middle;
}
The problem is that transitions animate a property when that property changes. For example, if I had a div that was 100px wide, then added a class to it that switched it to be 300px wide, you could set transition: width 3s and it would grow over that 3 second period.
In your case, all that's changing is display:block / display:hidden
To get it to transition, you'll need to change things so that, rather than hiding it with display:hidden, you're hiding it by shrinking it to be really tiny and growing, or changing the opacity, etc.

How can I fix my drop down?

if you open the following link
http://dev.scopedesign.com/client/nyfarmersmarket_02/
you find an navigation bar if you go on "ABOUT US" you will see a drop down..
then you se the problem in drop down
now i want to give you a little idea from how i make this..
I am working on joomla CMS, & i do some changes in navigation module to get my style now the follwing CSS i used for this.. the problem is it is displaying the .parent.active a
background in drop downs i dont want that for this purpose i made .parent.active a ul
but it doesnt work..
you can check this how it works by inspect element in the browser.
.parent.active a{
background-image:url(../images/selected.png);
background-repeat:repeat-x;
padding-top:13px;
padding-bottom:13px;
}
.parent.active a ul{
background-image:none !important;
background-repeat:none;
padding-top:0px !important;
padding-bottom:0px !important;!
}
.menusan
{
/* Use these parameters to positions your menu. */
position: absolute;
// left: 10px;
}
.menusan, .menusan li, .menusan li ul { /* all lists */
padding: 0;
margin: 0;
// list-style: none;
display:block;
float:left;
}
.menusan li a{
padding-left:20px;
padding-right:18px;
}
.menusan li a:hover{
background-image:url(../images/selected.png);
background-repeat:repeat-x;
padding-top:13px;
padding-bottom:13px;
}
.menusan li{ /* all list items */
padding-top:11px;
padding-bottom:11px;
// padding-left:20px;
// padding-right:18px;
-moz-border-right:#537d28 groove 2px;
border-right:#7cb43f groove 2px;
[border-right:#537d28 groove 2px;
border-right:#7cb43f groove 2px;/
border-right:#7cb43f groove 2px;]
}
.menusan li ul { /* second-level lists */
//top:35px;
margin-top:13px;
float:left;
position: absolute;
border: none;
left: -98%; /* Use left instead of display to hide menus; display: none isn’t read by screen readers. */
}
.menusan li ul li{
display:list-item;
float:none;
border: none;
background-color:#537d28;
color:#fff;
//padding:10px 10px 24px 10px;
}
.menusan li ul li:hover{
display:list-item;
float:none;
background-color:#96c73d;
}
.menusan li ul li a{
display:block;
float:left;
}
.menusan li ul li a:hover{
display:block;
float:left;
background-color:#96c73d;
}
.menusan li:hover ul, .menusan li.sfhover ul { /* lists nested under hovered list items */
left: auto; /* change is to 10px, 20px, etc for indenting the sub menu */
border: none;
display:block;
float:left;
}
/* **************** Dropdown Menu styling end here ***************/
One thing i specialy want to let you know guys that it is difficult to make div in it or cheange style name because it is a dynamic module.
Cleaned up and fixed your CSS, try this:
.navigation {
background-color:#537D28;
color:#fff;
float:left;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
height:40px;
margin-bottom:0.6em;
width:100%;
}
.menusan {
margin: 0;
list-style-type: none;
font-weight:700;
float: left;
color:#fff;
}
.menusan > li {
margin:0;
float: left;
border-right:1px groove #7cb43f;
position:relative;
}
.menusan li a {
display:block;
height:40px;
line-height:40px;
padding:0 25px;
text-decoration:none;
color:#fff;
}
.menusan .active {
background: url("http://dev.scopedesign.com/client/nyfarmersmarket_02/templates/nyfm/images/selected.png") repeat-x center center;
}
.menusan li a:hover {
background: url("http://dev.scopedesign.com/client/nyfarmersmarket_02/templates/nyfm/images/selected.png") repeat-x center center;
}
.menusan li.parent ul {
position:absolute;
z-index:9999;
top:40px;
left:0;
display:none;
background-color:#537D28;
}
.menusan li.parent:hover ul {
display:block;
}
.menusan li.parent ul a {
float:left;
}
.menusan li.parent ul a:hover {
background-color:#70A835;
}
.menusan li.parent ul a {
width:55px;
}

Resources