Blogger Drop Down Menus Try 2 - html

So after many hours of Google searches and many more editing and trying to understand CSS code for drop down menus in Blogger (Why doesn't Google just provide a widget for these anyway???), I now have an example that is 98% of the way to what I want. The HTML and CSS are attached. I'd really to make 2 changes which I couldn't figure out.
I'd like the top level menu to be centered on the page. Sounds easy but I didn't find it so
Under the PORTFOLIO menu, WILDLIFE/NATURE submenu, I'd like to shift the box of the the subsubmenu to be completely off of its parent menu, i.e. so no menu items in the PORTFOLIO menu are hidden.
I can live with this the way it is but if I can get these last 2 things done, I'd be golden. Thanks.
#cssnav {
float: left;
overflow: hidden;
}
#cssnav ul {
width: 100%;
margin: 0;
padding: 0px;
list-style:none;
}
#cssnav ul li {
float:left;
}
#cssnav ul li a {
float: left;
font: 16px Verdana, Helvetica, Sans-serif;
color:black;
padding: 10px 40px; /*1st number is top & bottom. 2nd is left & rght. */
text-decoration:none;
}
#cssnav ul li a:hover,
#cssnav ul li:hover > a {
color: black; /* main menu hover color */
}
#cssnav li ul a:hover,
#cssnav ul li li:hover > a {
color: black; /*submenu text color */
text-shadow: 0 1px rgba(255, 255, 255, 0.3);
}
#cssnav li ul {
left: -999em;
margin: 35px 0 0;
position: absolute;
width: 340px; /* width of submenu box */
z-index: 9999;
}
#cssnav li:hover ul {
left: auto; /* where the left edge of the drop down box aligns */
}
/* Drop down box formatting */
#cssnav li ul a {
margin-right: 0;
width: 260px;
border-bottom: 1px solid transparent;
border-top: 1px solid transparent;
}
#cssnav li li ul {
margin: -1px 0 0 160px;
visibility:hidden;
}
/* no idea what this does */
#cssnav li li:hover ul {
visibility:visible;
}
<div id="cssnav">
<ul>
<li>HOME</li>
<li>PORTFOLIO
<ul>
<li><a ref='http://www.adahighlanderphotography.com/Products/Landscapes'>
LANDSCAPES</a></li>
<li><a href=' '>WILDLIFE/NATURE</a>
<ul>
<li><a href='http://www.adahighlanderphotography.com/Products/WildlifeFlowers-1/Birds/'>
BIRDS</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/WildlifeFlowers-1/Butterflies/'>BUTTERFLIES</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/WildlifeFlowers-1/Flowers/'>FLOWERS</a></li>
</ul>
</li>
<li><a href='http://www.adahighlanderphotography.com/Products/2017-Photo-of-the-Week/'>PHOTO OF THE WEEK</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/Landscapes-1/2017-Michigan-Calendar-Photos/'>2017 CALENDAR PHOTOS</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/Notecards'>
NOTECARDS</a></li>
</ul>
<li>CONTACT ME</li>
<li>ABOUT ME</li>
</li></ul>
</div>

I've modified your code to achieve what you're looking for. I put width: 100% on your main navigation div, and used text-align: center and display: inline-block to center the menu.
Formatting the subnavs was a little more complicated. I added position: relative to the li elements so we could position the sub navs around their parents. In order to get the third-level subnav off of its parent, I applied left: 100% to it to move it all the way to the side. I also removed the margin style on the sub nav under Wildlife.
I also added some drop-shadow and additional :hover styling to make the experience a little better for the user.
Hope this helps! More comments in the CSS.
#cssnav {
width: 100%; /* Spanned div across page */
text-align: center; /* Centered <ul> inside */
}
#cssnav ul {
display: inline-block; /* Allows text-align:center to affect Menu */
margin: 0;
padding: 0px;
list-style:none;
}
#cssnav ul li {
float:left;
text-align: left; /* Keeps menus left aligned */
position: relative; /* Allows us to position sub menus relative to their parent */
}
#cssnav ul li a {
float: left;
font: 16px Verdana, Helvetica, Sans-serif;
color:black;
padding: 10px 40px; /*1st number is top & bottom. 2nd is left & rght. */
text-decoration:none;
}
#cssnav ul li a:hover,
#cssnav ul li:hover > a {
color: black; /* main menu hover color */
background: rgba(0,0,0,0.1);
}
#cssnav li ul a:hover,
#cssnav ul li li:hover > a {
color: black; /*submenu text color */
text-shadow: 0 1px rgba(255, 255, 255, 0.3);
}
#cssnav li ul {
left: 0;
display: none;
margin: 35px 0 0;
position: absolute;
width: 340px; /* width of submenu box */
z-index: 9999;
background: white;
box-shadow: 0px 6px 10px 0px rgba(0,0,0,0.25);
-webkit-padding-start:0px !important;
}
#cssnav li:hover ul {
display: block;
}
/* Drop down box formatting */
#cssnav li ul a {
margin-right: 0;
width: 260px;
border-bottom: 1px solid transparent;
border-top: 1px solid transparent;
}
#cssnav li li ul {
visibility:hidden;
}
/* no idea what this does */
#cssnav li li:hover ul {
visibility:visible;
left: 100%; /* Puts sub nav next to parent, not over it */
}
<div id="cssnav">
<ul>
<li>HOME</li>
<li>PORTFOLIO
<ul>
<li><a ref='http://www.adahighlanderphotography.com/Products/Landscapes'>
LANDSCAPES</a></li>
<li><a href=' '>WILDLIFE/NATURE</a>
<ul>
<li><a href='http://www.adahighlanderphotography.com/Products/WildlifeFlowers-1/Birds/'>
BIRDS</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/WildlifeFlowers-1/Butterflies/'>BUTTERFLIES</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/WildlifeFlowers-1/Flowers/'>FLOWERS</a></li>
</ul>
</li>
<li><a href='http://www.adahighlanderphotography.com/Products/2017-Photo-of-the-Week/'>PHOTO OF THE WEEK</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/Landscapes-1/2017-Michigan-Calendar-Photos/'>2017 CALENDAR PHOTOS</a></li>
<li><a href='http://www.adahighlanderphotography.com/Products/Notecards'>
NOTECARDS</a></li>
</ul>
<li>CONTACT ME</li>
<li>ABOUT ME</li>
</li></ul>
</div>

Related

Positioning the drop down menu

Hi Please help me on this issue.
Issue: dropdown values of the menu is shown in other menu (it is not in-line with menu).
Example: Dropdown values of Home menu is Home-1, Home-2, Home-3 and it will shown under National parties menu. How can I show appropriately under the right menu
Demo: http://jsfiddle.net/shrikanth/Sv79m/
<div id="menu">
<ul>
< li>Home<ul>
<li>Home-1</li>
<li>Home-2</li>
<li>Home-3</li>
</ul></li>
<li ><a href="aboutus.html">National Parties<ul>
<li>BJP</li>
<li>Congress</li>
<li>CPM</li>
</ul></a></li>
<li><a href="services.html">Services<ul>
<li>TV</li>
<li>Cell</li>
<li>Radio</li>
</ul></a></li>
<li>Contact Us
<ul>
<li>India</li>
<li>USA</li>
<li>SAUS</li>
</ul>
</li>
</ul>
</div>
CSS
#menu {
width: 550px;
height: 35px;
font-size: 16px;
font-family: Tahoma, Geneva, sans-serif;
font-weight: bold;
text-align: center;
text-shadow: 1px 2px 1px #333333;
background-color: #8AD9FF;
border-radius: 8px;
}
#menu ul {
height: auto;
padding: 8px 0px;
margin: 0px;
}
#menu li {
display: inline;
padding: 20px;
}
#menu ul li a {
text-decoration: none;
color: #00F;
padding: 8px 8px 8px 8px;
}
#menu a:hover {
color: #F90;
background-color: #FFF;
}
#menu ul li ul{
display:none;
position:absolute;
top:31px;
background-color:red;
}
#menu ul li:hover ul{
display:inline-block;
height:auto;
width:135px;
}
#menu ul li ul:before{
content: '';
border-color: transparent transparent red transparent;
border-style: solid;
border-width: 10px; /* The border on the drop down box */
position: absolute;
top: -20px;
left: 37%;
margin-left:10px;
}
http://jsfiddle.net/Sv79m/1/
Give #menu li a position of relative:
#menu li {
display: inline;
padding: 20px;
position:relative;
}
Adjust a little the absolute positioning with left:0 :
#menu ul li ul{
display:none;
position:absolute;
top:51px;
background-color:red;
left:0;
}
Edit:
Also, to solve the overlapping links, add this:
#menu ul li ul li{
display:block;
padding:5px;
}
http://jsfiddle.net/Sv79m/2/
Also, you had some unclosed tags, I closed them and now it's much better:
http://jsfiddle.net/Sv79m/3/
<a href="aboutus.html">National Parties<ul>
^^CLOSE ME!
It's all down to the positioning of the containing element. If you use position: relative; it allows you to position elements absolutely inside of it.
Here's a tutorial on creating a dropdown navigation, it explains about the positioning and structure. This should help - CSS 3 navigation menu

How do I add a horizontal submenu?

I would like to have a dropdown sub- menu in the same style, I know it's simple but I'm still new to making websites and I can't figure it out by myself.
here's the top part of my HTML file:
<!DOCTYPE html>
<html>
<head>
<title>Startpagina</title>
<LINK href="../CSS/stylesheet.css" rel=stylesheet>
</head>
<body>
<div class="schikking">
<img src="../Images/bibram.png" alt="Logo van de bib" height="90" width="170">
<!-- navigatie -->
<nav>
<ul>
<li><span class ="s2">Startpagina</span></li>
<li>Aanwinsten</li>
<li>Catalogus
<ul class="sub">
<li>Pages</li>
<li>Archives</li>
<li>New Posts</li>
</ul>
</li>
<li>Uitlening</li>
<li>Reservatie</li>
<li>Suggestie</li>
<li>Contact</li>
</ul>
</nav>
and a big part of my CSS file:
.schikking {
margin: 0 auto;
padding: 30px 0px 0px 0px;
max-width: 1010px;
}
.content {
background-color: red;
background-color: rgba(147, 4, 0, 0.84);
border: 1px solid black;
}
nav li
{
display: inline;
padding-right: 8px;
}
nav {
text-align: center;
margin: -20px 0px 0px 0px;
}
nav ul{
background-color: rgba(126, 4, 0, 0.79);
border: 1px solid black;
}
nav ul li{
display: inline;
}
nav ul li a{
padding-left: 1em;
padding-right: 1em;
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
color: lightgray;
}
nav ul li a:hover{
color: #999999;
}
nav ul ul{display: none; position: relative;}
nav li ul li{float:none;display: inline-block; }
nav ul li:hover ul {display: inline-block;}
heres a picture of how it looks atm:
normal: http://gyazo.com/8f6553245b736feee8cc5ebf8d4a030c
while hovering over "catalogus": http://gyazo.com/662eee4bbbb2ea2318925be76b3722d2
You have nearly got it. I have only made some minor changes to the CSS to make it work.
nav ul li { display: inline-block; height: 100%; } instead of just display: inline is required so that the each <li> takes up all the height of the "menu" otherwise there is a small gap between the bottom of the <li> and the sub-menu which would cancel the :hover event since you are out of the <li>. inline elements do not have height (or width), so changed to display: inline-block.
The CSS at the end is where the other changes are. Your code is:
nav ul ul{display: none; position: relative;}
nav li ul li{float:none;display: inline-block; }
nav ul li:hover ul {display: inline-block;}
The display code doesn't need to be anything more than
nav ul li:hover ul {
display: block;
}
But to position the sub-menu outside of it's normal flow (which is currently appearing next to the parent menu item), you need to add an absolute position to the sub-menu `.
nav ul ul {
display: none;
position: absolute;
}
If you want a horizontal menu, that should be all the changes needed, since your rule nav ul li { display: inline-block; }will already apply to the sub-menu list-items. If you want a vertical menu, you need to reset the display back to the default list-item or block with:
nav ul ul li {
display: block;
}
See demo
Don't do it yourself. I use this jquery plug-in and its great:
Superfish
If you are having problems with anything I'd reccomend you to google them first. Here's a generator (just choose the one you want and follow the instructions):
Css drop down menu maker
I would also reccomend you to actually learning the language and expanding your knowledge, as well as googling questions before posting them here.
HTML :
<nav>
<ul>
<li><span class ="s2">Startpagina</span></li>
<li>Aanwinsten</li>
<li>Catalogus
<ul class="sub">
<li>Pages</li>
<li>Archives</li>
<li>New Posts</li>
</ul>
</li>
<li>Uitlening</li>
<li>Reservatie</li>
<li>Suggestie</li>
<li>Contact</li>
</ul>
CSS :
nav {
margin: -20px 0px 0px 0px;
text-align: center;}
nav ul ul {
display: none;
padding-right: 8px;}
nav ul li:hover > ul {
display: block;}
nav ul {
background-color: red;
border: 1px solid black;
list-style: none;
position: relative;
display: inline-table;}
nav ul:after {
content: ""; clear: both; display: block;}
nav ul li {
float: left;}
nav ul li:hover a {
color: #999999;}
nav ul li a {
display: block;
padding-left: 1em;
padding-right: 1em;
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
color: lightgray;}
nav ul ul {
background: #5f6975; border-radius: 0px; padding: 0;
position: absolute; top: 100%;}
nav ul ul li {
float: none; position: relative;padding: 10px;}
nav ul ul li a {
color: #fff;}
nav ul ul ul {
position: absolute; left: 100%; top:0;}

Second level menu behaving abnormal

I have a menu created for my website in which I have second level menu aswell but the problem is that the second level menu has some problems:
It's size is bigger
It's menu items are floating right
It's going into another first level menu item's territory
I want to solve these problems but I am not able to do it on my own.
HTML:
<header>
<div class="welcome_area">
<p>Welcome, <b>Arkam Gadet</b>
</p>
</div>
<div class="menu">
<nav>
<ul style="z-index: 20;">
<li> My Profile
<ul style="display: none; background-color: #eee; box-shadow: 0px 0px 2px 3px #bbb; z-index: 1;">
<li>My Questions
</li>
<li>Settings
</li>
</ul>
</li>
<li>Inbox
</li>
<li>Notifications
</li>
</ul>
</nav>
</div>
</header>
CSS:
header {
background-color: #eee;
height: 45px;
box-shadow: 0px 2px 3px 1px #bbb;
}
a {
color: black;
text-decoration: none;
}
h2 {
color: #f79a1d;
}
.welcome_area {
float: left;
margin-left: 5%;
}
.menu {
float: right;
margin-right: 5%;
}
.menu nav > ul {
position: relative;
}
.menu nav ul li {
display: inline;
padding: 5px;
}
.menu nav ul li a {
padding: 2px;
}
.menu nav ul li a:hover {
background: #eee;
border: 0;
border-radius: 3px;
box-shadow: 0px 0px 2px 1px #000;
}
.menu nav > ul ul {
position: absolute;
left: 0;
}
.menu nav > ul li > ul li {
display: block;
}
Demonstration.
As you can see in the fiddle the items are floating towards right in the second level menu, I want them to
Float left the second level menu items
Shorten the second level menu's width
Send them back of the navbar.
Prevent it from going into another first level menu item's place.
Here are my responses to your issues and a corresponding Fiddle.
1) Float left the second level menu items
Removed padding.
.menu nav ul { padding:0px; }
Also repositioned drop-downs (tweak this as neccessary):
.menu nav > ul ul {
position: absolute;
left: 5px;
top:22px;
}
2) Shorten the second level menu's width
Was this satisfied by #1?
3) Send them back of the navbar.
Added position and z-index.
.menu nav ul li a {
position:relative;
padding: 2px;
z-index:5;
}
This positions the drop-downs behind the main <a>s.
However, if you want the drop-downs to come from behind the actual menu bar (gray bar), you'll need to restructure things.
4) Prevent it from going into another first level menu item's place.
I'm not sure what this means. Possible to clarify?
Add this to your css
.menu nav ul li ul {
padding:0px;
margin-left:45px;
}
Demo

CSS Dropdown menu with horizontal submenu

I have the following site http://jsfiddle.net/Me4fw/4/ in which I am attempting to implement a horizontal css drop down menu that has a submenu which is also horizontal. I have tried everything but nothing seems to get the submenu items to sit inline with each other. All I can get them to do is mash up ontop of each other and be ugly/unreadable.
You problem is that you are placing the sub-menu absolutly positioned to the parent li. But the parent li has a small width.
The solution is to place the sub-menu absolutely positioned to the menu wrapper.
See this link with a working presentation!
UPDATE YOUR CSS:
#menu {
width: 820px;
height: 60px;
margin: 0 auto;
padding: 0px 40px;
position: relative;
}
#menu li {
float: left;
}
#menu ul ul {
list-style-type: none;
position: absolute;
z-index: 500;
left: 0;
right: 0;
}
AND DELETE THIS CSS:
#menu ul li ul li #jackie_spencer{
display: inline;
position: absolute;
top: 20px;
left: 0;
width: 100px;
color: #FFF;
}
Note:
You can view the source and check the CSS:
where it reads "updated", some definitions were changed!
Where it reads "updated, deleted", the declarations were deleted.
I took a look at your page, and the reason your submenu is vertical is the submenu <ul> is too narrow: its width is the same as enclosing <li>. You should set a width on it to make it take up all available space.
Making it left-aligned with the parent element and right-aligned with the right end of the menu bar is tricky. You might just want to set it to something wide enough to hold everything you know will be in it, and assume there won't be any reflow.
You also could use some JavaScript to calculate the right positions for it. JQuery is good for that. You'd only need to set those once when the page is first loaded, as part of $(document).ready().
Some tweaks to give second level submenus:
/* Menu */
#menu { /* UPDATED */
width: 820px;
height: 60px;
margin: 0 auto;
padding: 0px 40px;
position: relative;
}
#menu ul {
margin: 0;
padding: 0px 0px 0px 0px;
line-height: normal;
line-style: none;
list-style-type: none;
}
#menu a {
display: block;
height: 20px;
margin-right: 1px;
padding: 10px 20px 0px 20px;
/* height: 40px;
margin-right: 1px;
padding: 20px 20px 0px 20px;*/
text-decoration: none;
text-transform: uppercase;
font-family: 'Abel', sans-serif;
font-size: 16px;
font-weight: normal;
color: #FFFFFF;
border: none;
}
#menu a:hover {
background: url(images/page-content-bg.png) repeat;
}
#menu ul ul a:hover {
background: url(images/page-menu-bg.png) repeat;
}
#menu .current_page_item a {
background: url(images/page-content-bg.png) repeat;
}
#menu li { /* UPDATED */
float: left;
}
/* UPDATED, REMOVED
#menu ul li ul li #jackie_spencer{
display: inline;
position: absolute;
top: 20px;
left: 0;
width: 100px;
color: #FFF;
}
*/
#menu ul ul { /* UPDATED */
list-style-type: none;
position: absolute;
z-index: 500;
left: 50px;
right: 0;
}
#menu ul ul ul {
position: absolute;
/* top: 0;
left: 100%;*/
z-index: 500;
left: 50px;
right: 0;
}
div#menu ul ul,
div#menu ul li:hover ul ul,
div#menu ul ul li:hover ul ul
{display: none;}
div#menu ul li:hover ul,
div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}
div#menu ul ul li:hover { background:#c0c0c0;}
div#menu ul ul li { background:#cccccc;}
div#menu ul ul li a:hover { color:#000;}
Page code
<div id="menu">
<ul>
<li class="current_page_item"><a id="home_menu" href="#Home">Home</a><ul>
<li>linkx</li>
<li>linkx</li>
<li>linkx</li>
<li>linkx</li>
<li>linkx</li>
<li>linkx
<ul>
<li>linky</li>
<li>linky</li>
<li>linky</li>
<li>linky</li>
<li>linky</li>
<li>linky</li>
</ul>
</li>
</ul></li>
<li><a id="aboutus_menu" href="#About_Us">About Us</a><ul>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</ul></li>
</ul>
<ul>
<li><a id="what_we_do" href="#What_We_Do">What We Do</a>
<ul>
<li><a id="jackie_spencer" href="#Jackie_Spencer">Hypnotherapy</a></li>
<li><a id="diana_menz" href="#Diana_Menz">Massage</a></li>
<li><a id="afton_land" href="#Jackie_Spencer">Estitician</a></li>
</ul>
</li>
</ul>
<ul>
<li><a id="contactus_menu" href="#Contact_Us">Contact Us</a><ul>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</ul></li>
</ul>
</div>

Copy table tag formatting to ul & li tags

add List Image and Background Image to <li> items...
CSS Code :-
.sidebarmenu ul{
margin: 0;
padding: 0;
list-style-type: disc;
font:bold 14px Verdana;
width: 180px; /* Main Menu Item widths */
border: 2px solid skyblue;
}
.sidebarmenu ul li{
position: relative;
}
/* Top level menu links style */
.sidebarmenu ul li a{
display: list-item;
overflow: auto; /*force hasLayout in IE7 */
color: red;
text-decoration: none;
padding: 6px;
border-bottom: 1px solid #778;
border-right: 1px solid #778;
}
.sidebarmenu ul li a:link, .sidebarmenu ul li a:visited, .sidebarmenu ul li a:active{
background-color: lightblue;/*background of tabs (default state)#012D58*/
}
.sidebarmenu ul li a:visited{
color: black;
}
.sidebarmenu ul li a:hover{
background-color: lightskyblue;
}
/*Sub level menu items */
.sidebarmenu ul li ul{
position: absolute;
width: 170px; /*Sub Menu Items width */
top: 0;
visibility: hidden;
}
.sidebarmenu a.subfolderstyle{
background: url(images/right.gif) no-repeat 97% 50%;
}
HTML FORM:-
<body>
<div class="sidebarmenu">
<ul id="sidebarmenu1">
<li>Add Location
<ul>
<li>Add Flat</li>
<li>Add Area</li>
</ul>
</li>
<li>Log Out</li>
</ul>
</div>
</body>
first of all... your table structure and your ul-li structure is different:
table cells are all on same level // li levels are different
link names are different
i guess what you want to do is:
set the "images/user_manager.jpg" Image to the list-style-image
as we dont see the images and dont know what they are looking like i
believe you want to set the "images/bg.jpg" Image as the
background-image of the li-tags
in situations like that a screenshot or link would be nice.