tabular navigation using only css - css

I have a tabular navigation list (with the styles I choose for) in an external file contains the following code:
.tabs
{
position:relative;
text-align:left; /* This is only if you want the tab items at the center */
width: 90%;
padding: 0;
margin: 0;
/*border: 1px solid green;*/
}
.tabs ul.menu
{
list-style-type:none;
display:block; /* Change this to block or inline for non-center alignment */
width:570px;
/* min-width:570px;
max-width:800px;
vertical-align: bottom;
/*border: 1px solid red;*/
}
.tabs ul.menu > li
{
display:inline;
float:center;
vertical-align: bottom;
/** border: 1px solid yellow;*/
cursor:hand;
}
.tabs ul.menu li > a
{
color:#7a7883;
text-decoration:none;
display:inline-block;
text-align:center;
border:1px solid #f1f3f4;
padding:5px 10px 5px 10px;
width: 25%;
font-size:15px;
font-family:"Times New Roman", Times, serif;
border-top-left-radius:5px; -moz-border-radius-topleft:4px; -webkit-border-top-left-radius:5px;
border-top-right-radius:5px; -moz-border-radius-topright:4px; -webkit-border-top-right-radius:5px;
-moz-user-select:none;
cursor:hand;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#aeb8c0));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #aeb8c0, #fff);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #aeb8c0, #fff);
/* IE 10 */
background: -ms-linear-gradient(top, #aeb8c0, #fff);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #aeb8c0, #fff);
}
.tabs ul.menu li > a:hover
{
color: #fff;
cursor:hand;
}
.tabs ul.menu li > div
{
display:none;
position:absolute;
width:98%;
/* max-width:700px;*/
min-height:230px;
left:0;
margin: 0 15px 0 15px;
z-index:-1;
text-align:left;
padding:0;
}
.tabs ul.menu li > div > p
{
border:1px solid #f1f3f4;
background-color: #f5f9fc;
width: 99%;
padding:10px;
margin:0;
color: #65636e;
font-size:12px;
font-family:"Times New Roman", Times, serif;
text-decoration: none;
min-height:200px;
}
.tabs ul.menu li > a:focus
{
color: #f5f9fc;
}
.tabs ul.menu li:target > a
{
cursor:default;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f1f3f4), to(#fff));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #fff, #f1f3f4);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #fff, #f1f3f4);
/* IE 10 */
background: -ms-linear-gradient(top, #fff, #f1f3f4);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #fff, #f1f3f4);
cursor:hand;
}
.tabs ul.menu li:target > div
{
display:block;
}
and in the web page I have this:
<!-- Side NAVIGATION -->
<!-- Wrapper 2-Content -->
<div class="wrapper" style="min-height: 200px;"">
<!-- content -->
<div class="content">
<div class="tabs">
<ul class="menu">
<li id="item-1">
Bla Bla 1
<div><p>Tab Content 1</p></div>
</li>
<li id="item-2">
Bla Bla 2
<div><p>Tab Content 2</p></div>
</li>
<li id="item-3">
Bla Bla 3
<div><p>Tab Content 3</p></div>
</li>
</ul>
</div>
</div>
<!-- content -->
<!-- end of Side NAVIGATION -->
All goes fine except that it displays the tabs only without the box where the content should appear. I want one of the contents to be visible as default. I just don't know how to activated it without using javaScript.
Thank you in advanced.

add display : block as style for the div which u want to display by default. For example see this fiddle I hv created for making item1 visible on run http://jsfiddle.net/X6Agf/
<div style="display:block"><p>Tab Content 1</p></div>

Related

css a:hover to a:focus

I am making a website for my brother and I did a dropdown CSS menu for him which worked on the :hover to display the secondary options. Then he decided he wanted people to click on the main navigation box which would then dropdown the menu to show the secondary levels...
I tried changing the :hover to :focus (also the a:active) on the a element and this worked fine in IE9, but Firefox, Safari, Chrome and Opera wouldn't recognise the new commands. I read about a Javascript alternative but I'm not familiar with it too much to really feel confident about going down that route.
Just wondering if someone could help:
Link to web: http://www.doogledesigns.co.uk/prime%20elements/website/
HTML Code:
<div class="nav1">
<div class="menu-item-home">
<h4>Home</h4>
<ul>
<li>Plumbing & Gas Work</li>
<li>Electrical Work</li>
<li>Extensions</li>
<li>Internal & External Developments</li>
</ul>
</div>
<div class="menu-item-garden">
<h4>Garden</h4>
<ul>
<li>Garden Maintenance</li>
<li>Landscaping</li>
<li>Patios & Driveways</li>
<li>Walls & Fencing</li>
<li>Ponds & Water Features</li>
<li>Lighting</li>
<li>Drainage</li>
</ul>
</div>
<div class="menu-item-construction">
<h4>Construction</h4>
<ul>
<li>Home Redevelopment</li>
<li>New Builds</li>
<li>Driveways</li>
</ul>
</div>
</div>
CSS Code:
.nav1 {
float: left;
background: #404041;
height: 500px;
line-height: 1.5;
width: 170px;
-webkit-box-shadow: 2px 2px 5px rgba(0,0,0,2);
-moz-box-shadow: 2px 2px 5px rgba(0,0,0,2);
box-shadow: 2px 2px 5px rgba(0,0,0,2);
}
.menu-item-home, .menu-item-garden, .menu-item-construction {
background: #404041;
width: 170px;
}
.menu-item-home h4, .menu-item-garden h4, .menu-item-construction h4 {
color: #fff;
font-size: 13px;
font-weight: 500;
padding: 7px 12px;
background: #10702a;
}
.menu-item-home h4 a, .menu-item-garden h4 a, .menu-item-construction h4 a {
color: #fff;
display: block;
text-decoration: none;
width: 170px;
}
/* Menu Header Styles */
.menu-item-home h4, .menu-item-garden h4, .menu-item-construction h4 {
border-bottom: 1px solid rgba(0,0,0,3);
border-top: 1px solid rgba(225,225,225,0.2);
color: #fff;
font-size: 13px;
font-weight: 500;
padding: 7px 12px;
/* Gradient */
background: #a90329; /* Old browsers */
background: -moz-linear-gradient(top, #02942a 0%, #0b872d 44%, #0f722a 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#02942a), color-stop(44%,#0b872d), color-stop(100%,#0f722a)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #a90329 0%,#80b872d 44%,#0f722a 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #02942a 0%,#0b872d 44%,#0f722a 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #02942a 0%,#0b872d 44%,#0f722a 100%); /* IE10+ */
background: linear-gradient(top, #02942a 0%,#0b872d 44%,#0f722a 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#02942a', endColorstr='#0f722a',GradientType=0 ); /* IE6-9 */
}
/* ul styles */
.menu-item-home ul, .menu-item-garden ul, .menu-item-construction ul {
background: #404041;
font-size: 12px;
line-height: 30px;
height: 0px;
list-style-type: none;
overflow: hidden;
padding: 0px
}
.menu-item-home ul a, .menu-item-garden ul a, .menu-item-construction ul a {
margin-left: 2.5px;
text-decoration: none;
color: #404041;
diplay: block;
width: 173px;
}
/* li styles */
.menu-item-home li, .menu-item-garden li, .menu-item-construction li {
border-bottom: 1px solid #eee;
}
.menu-item-home li:hover, .menu-item-garden li:hover, .menu-item-construction li:hover {
background: #eee;
}
/* ul styles */
.menu-item-home ul, .menu-item-construction ul, .menu-item-garden ul {
background: #fff;
font-size: 12px;
line-height: 30px;
min-height: 0px;
max-height: 0px /* collapses the menu */
list-style-type: none;
overflow: hidden;
padding: 0px;
/* Animation */
-webkit-transition: height 1s ease;
-moz-transition: height 1s ease;
-o-transition: height 1s ease;
-ms-transition: height 1s ease;
transition: height 1s ease;
}
.menu-item-home:hover ul {
height: 155px;
}
.menu-item-garden:hover ul {
height: 220px;
}
.menu-item-construction:hover ul {
height: 90px;
}
CSS sheet needs cleaning up a bit but you get the general jist!
You want that menu to appear on click event.
To make that possible and to also make that cross browser compatible i would recommend using a jquery library jQuery just download the library and attach the link in the <head> section of your page and simply write jquery code to attach click event handler.
jQuery Download Link
basically you need to code only this much
after you link the jquery to your page write this in
<script>
$(document).ready(function(){
$(".menu-item-home a").click(function(){
$(".menu-item-home ul").slideToggle('slow');
});
$(".menu-item-garden a").click(function(){
$(".menu-item-garden ul").slideToggle('slow');
});
$(".menu-item-construction a").click(function(){
$(".menu-item-construction ul").slideToggle('slow');
});
});
</script>
and a little change to css is also required.and thats it you wana do.
have changed your css code and witten the jquery code for you for your website
check this link and you will have both your changed code.
and on the right side is the working website with click enabled.
http://jsfiddle.net/znsZu/
Hope it helps.

Cant remove space between Header and Menu Nav bar

I for whatever reason cannot get rid of the gap between my header and the nav bar menu. I've tried every adjustment of padding/margins I can think of to either push it up or move the bar, but it just does funky stuff with the menu or pushes other content up. I need some help.
and the code
#header_wrap {
width:100%;
height:144px;
text-align: center;
}
#header {
width:980px;
margin:0 auto;
}
#preloadedImages
{
width: 0px;
height: 0px;
display: none;
background-image:url(Logo/logo14hover.gif);
}
.site_logo {
float:left;
width:302px;
height:144px;
background:url(Logo/logo14.gif) no-repeat;
}
.site_logo:hover {
float:left;
width:302px;
height:144px;
background:url(Logo/logo14hover.gif) no-repeat;
}
.headerpic {
float:left;
width:678px;
height:144px;
background:url(Images/headerpic.gif) no-repeat;
}
#menu_wrap {
position:relative;
z-index:2;
text-align:center;
width:100%;
padding: 0px 0px;
}
#menu {
position:relative;
z-index:2;
width:1000px;
text-align:center;
margin:0 auto;
height:61px;
padding: 0px 0px;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom, #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
box-shadow: 0px 0px 9px rgba(0,0,0,0.5);
padding: 0px 0px;
list-style:none;
position: relative;
display:inline-table;
text-decoration:none;
font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif;
font-size:17px;
color:#FFFFFF;
font-weight:light;
outline:none;
text-shadow: 1px 1px #000000;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #736e57;
background: linear-gradient(top, #BBB38F 0%, #6B6441 40%);
background: -moz-linear-gradient(top, #BBB38F4 0%, #6B64415 40%);
background: -webkit-linear-gradient(top, #BBB38F 0%,#6B6441 40%);
text-decoration:none;
font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif;
font-size:17px;
color:#FFFFFF;
font-weight:light;
outline:none;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li:hover a {
color:#FFFFFF;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li a {
color:#FFFFFF;
display: block;
padding: 12px 42px;
text-decoration:none;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li:hover > ul {
background: #303030;
text-decoration:none;
display: block;
}
nav ul ul {
background: #303030;
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:14px;
text-decoration:none;
color:#000;
font-weight:light;
outline:none;
filter:alpha(opacity=95);
opacity: 0.95;
-moz-opacity:0.95;
}
nav ul ul li {
text-decoration:none;
float: none;
position: relative;
}
nav ul ul li a {
text-decoration:none;
padding: 0px 0px;
color:#000;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul li a:hover {
text-decoration:none;
background: #736e57;
text-shadow: 1px 1px #000000;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul {
text-decoration:none;
padding: 0px;
position: absolute;
}
nav ul ul li {
float: none;
position: relative;
}
nav ul ul li a {
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
padding: 10px 40px 10px 15px;
color:#000;
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:15px;
text-align: left;
}
nav ul ul li a:hover {
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:15px;
background: #6B6441;
text-align: left;
background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom, #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul ul {
position: absolute;
left: 100%; top:0;
}
and the HTML
<div align="center" id="header_wrap">
<div id="header">
<div id="preloadedImages"></div><div class="site_logo"></div>
<div class="headerpic"></div>
</div>
</div>
<!-- START MENU NAV BAR CODE -->
<div id="menu_wrap">
<div id="menu">
<nav>
<ul>
<li>Company
<ul>
<li>Mission</li>
<li>Philosophy</li>
</ul>
</li>
<li>Solutions
<ul>
<li>Q Pipe Estimator
<ul>
<li>Advantage</li>
<li>Differentiator</li>
<li>Features</li>
<li>Screen Shots</li>
</ul>
</ul>
</li>
</li>
<li>Services
<ul>
<li>Technical Support</li>
<li>Training</li>
<li>Customization</li>
<li>FAQ's</li>
</ul>
</li>
<li>Industry
<ul>
<li>Focus</li>
<li>Customers</li>
</ul>
</li>
<li>Contact
<ul>
<li>Contact Information</li>
<li>Request Information</li>
</ul>
</li>
<li>Login
</li>
</ul>
</nav>
</div>
</div>
<!-- END MENU NAV BAR CODE -->
added fiddle link in comments
Simply remove the default margin for your main ul (the direct descendant of nav)
Select it using the following CSS, or giving that specific ul a class or id (this way you target only the ul causing you trouble).
nav > ul {margin: 0}
I stuck it into the top of your fiddle, and updated it here
I realise this has now been answered because I took way too long formatting this, but I'd just like to point out that it has nothing to do with the box-shadow which has no impact on positioning.
The ul default margin is responsible for this space. Try setting margin-top:0 to nav ul. Demo: http://jsfiddle.net/xtsAx/8/
for me the error was because i used dream weaver to edit my code.
this give me a hiccup by adding default headers.
when i removed those headers and just gave<html> <head>...<?php>....?> .... </html> it worked perfect.
always remove html tags and header by dream weaver.
**Update: I had the same error again in Firefox so i applied
*{
margin:0;
padding:0;
}
And hence got rid of it completely now.
**

CSS Menu problems: Submenu appears active when parent menu item is active (current) page

I am soooo confused! Here is the site I'm developing: Cancer Support site
I seem to have two problems... that I have spent hours and hours trying to figure out the solution.. so I really hope someone can help.
Problem 1: I use an ID=navactive to keep the parent menu item active if it is the current page being diplayed. That works. However, the way I have coded the CSS, it has introduced an error by making the submenu items appear active when they first appear upon mousever of an ID=navactive parent. Instead the submenu items should initially appear as inactive until they are actually moused over. On the site, you can see that the "Home" page is the active page on the parent menu. If you mouse over it, the two children submenus appear.. but they show up active. They should appear as inactive - the same way as the submenus do when you mouse over the "Our Work" parent menu item.
Problem 2: None of my grandchildren submenu items appear at all.. Under both the "Home" and "Our Work" parent menu items I have the following configuration:
Top level menu (parent)
Submenu 1 (child 1)
Submenu 2 (grandchild 1)
Submenu 3 (child 2)
Instead it appears on the page like this where the grandchild 1 becomes the child 2, and no grandchildren are viewable (and the original child 2 [submenu 3] is missing):
Top level menu (parent)
Submenu 1 (child 1)
Submenu 2 (child 2)
Any suggestions would be greatly appreciated!!!
Thanks!
For your convenience.. here is my css code for the nav menu section:
#navcontainer
{
width: 711px;
height: 25px;
text-align: center;
margin: 0px auto; /*Center container on page*/
clear: both;
background-color: #129F9F;
border: 3px solid #FFFFFF;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Opera */
background-image: -o-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #16ACAC), color-stop(1, #0D6F6F));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #16ACAC 0%, #0D6F6F 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #16ACAC 0%, #0D6F6F 100%);
}
.main_menu
{
height: 24px;
line-height: 24px;
font-size: 12px;
position: relative;
}
.main_menu ul
{
padding: 0px 0px 0px 35px; /* padding on left to get nav menu to center.. since it has a float left to make it display properly*/
list-style: none;
}
.main_menu ul li
{
padding: 0;
margin: 0;
border-right: 2px solid #129F9F;
float: left;
}
.main_menu ul li.navcontact /* to stop right border at end of nav line */
{
padding: 0;
margin: 0;
border-right: none;
float: left;
}
.main_menu ul li a
{
color: #FFF;
display: block;
text-decoration: none;
padding: 0 15px;
}
.main_menu ul > li:hover > a, #navactive a:link, #navactive a:visited, #navactive > ul > li > a:hover
{
text-decoration: none;
color: #EAA339;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Opera */
background-image: -o-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #0D6F6F), color-stop(1, #16ACAC));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #0D6F6F 0%, #16ACAC 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #0D6F6F 0%, #16ACAC 100%);
}
.main_menu ul li ul
{
display: none;
width: auto;
position: absolute;
padding: 0px;
margin: 0px;
}
.main_menu ul li:hover ul
{
display: block;
position: absolute;
margin: 0;
padding: 0;
}
.main_menu ul li:hover li
{
float: none;
list-style: none;
margin: 0px;
}
.main_menu ul li:hover li
{
font-size: 12px;
height: 24px;
background: #54C4C4;
/* border-top: 1px solid #129F9F; */
border: 1px solid #FFFFFF;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
}
.main_menu ul li:hover li a
{
font-size: 11px;
color: #fff;
padding: 0px;
display: block;
width: 150px;
}
.main_menu ul li li a:hover
{
font-size: 11px;
height: 24px;
color:#EAA339;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
}
And here is the HTML code:
<div id="navcontainer">
<div class="main_menu">
<ul>
<li id="navactive">Home
<ul>
<li>submenu 1
<ul>
<li>submenu 2</li>
</ul>
</li>
<li>submenu 3</li>
</ul>
</li>
<li>What is CSFF
<ul>
<li>submenu 4</li>
</ul>
</li>
<li>Make a Donation</li>
<li>Our Work
<ul>
<li>submenu 5
<ul>
<li>submenu 6</li>
</ul>
</li>
<li>submenu 7</li>
</ul>
</li>
<li>Events Outline</li>
<li class="navcontact">Contact Us</li>
</ul>
</div>
</div>
The reason you are getting this problem is due to your CSS and the way you have structured your HTML code. Here is your problem -
.main_menu ul > li:hover > a, #navactive a:link, #navactive a:visited, #navactive > ul > li > a:hover
{
STYLES
}
Simply change the "#navactive a:link" part of your CSS code above to a seperate class that handles the active link. Currently any link within the "navactive" div will inherit the styles given in this class, and this is why the sub menu text is appearing yellow and not white. So like I said change the above CSS code to a separate class, eg - "#navactive .current"
and then change your HTML code to look like this:
<div id="navcontainer">
<div class="main_menu">
<ul>
<li id="navactive"><a class="current" href="index.asp" title="Cancer Support for
Families Foundation is a community funded, community focused cancer charity.">Home</a>
That should do the trick! Obviously I haven't been able to test it, but let me know if you have any problems. Also just a tip - using the Chrome 'Inspect Element' function is really useful when faced with these kind of problems!
Problem 1
in the css:
.main_menu ul > li:hover > a, #navactive a:link, #navactive a:visited, #navactive > ul > li > a:hover
you should put a > in #navactive a:visited, and #navactive a: link so it looks like this:
.main_menu ul > li:hover > a, #navactive > a:link, #navactive > a:visited, #navactive > ul > li > a:hover
the ">" means you direct only the child element

Joomla loads only certain parts of css template

I am working on a Joomla! template and I have my index and my template.css
When I leave all the design in css it appears to load only those parts concerning css classes and doesnt do anything else, so eventually I have to write everything else into de index.php which is silly because Im not supposed to.
For instance this is the code I want for my index.php
<!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" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/posgradostemplate/css/template.css" type="text/css" />
<jdoc:include type="head" />
</head>
<body>
<div id="wrapper">
<div id="content">
<div class="mainmenu">
<jdoc:include type="modules" name="mainmenu" />
</div>
</div>
</div>
</body>
</html>
But wrapper and content do not behave as expected and no background is shown. This is my css file:
html {
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #E6E6E6 0%, #858585 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #E6E6E6 0%, #858585 100%);
/* Opera */
background-image: -o-linear-gradient(top, #E6E6E6 0%, #858585 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #E6E6E6), color-stop(1, #858585));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #E6E6E6 0%, #858585 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #E6E6E6 0%, #858585 100%);
margin: 0;
padding: 0;
border: 0;
}
html, body {
height: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
}
.mainmenu ul {
font-family: Arial, Verdana;
font-size: 12px;
margin: 0;
padding: 0;
list-style: none;
}
.mainmenu ul li {
display: block;
position: relative;
float: left;
}
.mainmenu li ul {
display: none;
}
.mainmenu ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #000000;
padding: 5px 15px 5px 15px;
background: #000000;
margin-left: 1px;
white-space: nowrap;
}
.mainmenu li:hover li a:hover {
background: #FFFF00;
color: #FF0000;
}
.mainmenu ul li a:hover {
background: #000000;
color: #FFFF00;
}
.mainmenu li:hover ul {
display: block;
position: absolute;
}
.mainmenu li:hover li {
background: #FFFF00;
float: none;
font-size: 11px;
color : #000000;
}
.mainmenu li:hover a {
background: #FFFF00;
color : #000000;
}
#wrapper{
width: 100%;
text-align: center;
}
#content{
display: inline-block;
}
Everything other than mainmenu is not working as the css tells it to. I am thinking that it is not being loaded properly, I want it to be loaded eagerly, so that everything is had in mind. Right now it only works if I add the css code in the index and it should not be that way. Suggestions?
Try loading the CSS file using the following:
$document = JFactory::getDocument();
$document->addStyleSheet(JURI::root() . "templates/posgradostemplate/css/template.css");

How can I convert to a CSS Drop down menu

New to CSS. I've got a Horizontal menu that I want to convert to a drop down menu.
Here's the CSS:
.menu_container {
position:relative;
}
ul.semiopaquemenu{ /* main menu UL */
font-family: 'Metrophobic', Arial, serif; font-weight: 800;
font-size:18px;
width: 100%;
background: #ccc;
padding: 11px 0 8px 0; /* padding of the 4 sides of the menu */
margin: 0;
text-align: left; /* set value to "left", "center", or "right" to align menu accordingly */
}
ul.semiopaquemenu li{
display: inline;
}
ul.semiopaquemenu li a{
color:white;
padding: 6px 8px 6px 8px; /* padding of the 4 sides of each menu link */
margin-right: 15px; /* spacing between each menu link */
text-decoration: none;
}
ul.semiopaquemenu li a:hover, ul.semiopaquemenu li a.selected{
color: #0080FF;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwLjgyIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMC4xNiIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); /* IE9+ SVG equivalent of linear gradients */
background: -moz-linear-gradient(top, rgba(255,255,255,0.82) 0%, rgba(255,255,255,0.16) 100%); /* fade from white (0.82 opacty) to 0.16 opacity */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.82)), color-stop(100%,rgba(255,255,255,0.16)));
background: -webkit-linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
background: linear-gradient(top, rgba(255,255,255,0.82) 0%,rgba(255,255,255,0.16) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d1ffffff', endColorstr='#29ffffff',GradientType=0 );
-moz-box-shadow: 0 0 10px #595959; /* CSS3 box shadows */
-webkit-box-shadow: 0 0 10px #595959;
box-shadow: 0 0 10px #595959;
padding-top: 12px; /* large padding to get menu item to protrude upwards */
padding-bottom: 9px; /* large padding to get menu item to protrude downwards */
}
.semiopaquemenu ul {
position:absolute;
left:-9999px;
top:-9999px;
list-style-type:none;
}
.semiopaquemenu li:hover {
position:relative;
}
.semiopaquemenu li:hover ul {
left:0px;
top:30px;
padding:3px;
width:160px;
}
.semiopaquemenu li:hover ul li {
height:18px;
border:none;
}
.semiopaquemenu li:hover ul li a {
height:18px;
padding:0px;
display:block;
width:158px;
line-height:18px;
text-indent:5px;
}
.semiopaquemenu li:hover ul li a:hover {
height:18px;
}
Here's my HTML:
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>Options</li>
</ul>
How can I convert menu item "Options" to a drop down???
Thanks!
demo jsBin
Add this lines and play around:
CSS:
ul.semiopaquemenu > li > ul{
background:#ccc;
padding:15px 20px;
}
ul.semiopaquemenu > li > ul li {
color:white;
cursor:pointer;
display:block;
padding:4px 10px;
}
HTML:
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>
Options
<ul>
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
<li>Option 4</li>
</ul>
</li>
</ul>
Well, for starters you'll need some extra list items to actually have something to "drop down", so another <ul>. The place to put it is <li>Options RIGHT HERE </li>. To get something going, just copy/paste the HTML you already have into itself at that point:
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>Options
<ul class="semiopaquemenu">
<li>Home</li>
<li>Messaging</li>
<li>Directory</li>
<li>Options</li>
</ul>
</li>
</ul>
Which with your current CSS produces this, a working drop down menu: http://jsfiddle.net/yAmWb/

Resources