Is anybody aware of any CSS tricks that can achieve the tabbed rectangle look as shown in the image below.
Obviously this cannot be achieved using one div, however, can anybody come up with a better method than overlapping one div over another to make a gap in the border?
This is my current solution, but I feel it could be better:
HTML:
<div id="handle"></div>
<div id="menu"></div>
CSS (Have ignored colors and positioning etc):
#handle {
width: 90px;
height: 20px;
border-left: 1px solid #666;
border-right: 1px solid #666;
}
#menu {
width: 600px;
height: 100px;
border: 1px solid #666;
margin-top: 19px; /* Notice it is one pixel higher then the bottom of the #handle, this covers the top border where the handle is */
}
Please do not correct the above CSS if there are mistakes, I have not tested this. It is purely to show my current method of achieving this
Any comments much appreciated
UPDATE
This is the HTML for the menu as it stands:
<nav id="global-nav">
<ul>
<li id="homNav"></li>
<li id="masNav">#
<!-- This is where the submenu starts -->
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
<!-- This is where the submenu ends -->
</li>
<li id="shiNav">#
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
</li>
<li id="repNav">#
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
</li>
<li id="setNav">#
<div class="handle"></div>
<div class="subMenu">
<!-- Content Here -->
</div>
</li>
</ul>
</nav>
This is the CSS for the menu as it stands (I have not included the sub menu css yet):
/* Navigation */
#global-nav {position:absolute;width:460px;height:27px;left:15px;top:43px;}
#global-nav ul {margin:0;padding:0;list-style-type:none;}
#global-nav ul li {position:relative;display:block;width:92px;height:27px;float:left;padding:0;margin-left:8px;z-index:10;cursor:pointer;background-image:url("http://beta.example.net/_images/_global/sprite.png");background-position:-173px -32px;}
#global-nav ul li:hover {background-position:-173px -59px;}
#global-nav ul li:active {background-position:-173px -86px;}
#global-nav ul li a {display:block;width:92px;height:27px;line-height:27px;text-align:center;color:#fff;font-size:12px;text-shadow:#666 0 -1px 0;}
#global-nav ul li:hover a {color:#666;text-shadow:#fff 0 1px 0;}
#global-nav ul li:active a {color:#666;text-shadow:none;}
/* Set styles for specific navigation buttons */
#homNav {width:47px !important;margin-left:0 !important;margin-right:12px;background-position:-126px -32px !important;}
#homNav a {width:47px !important;}
#homNav:hover {background-position:-126px -59px !important;}
#homNav:active {background-position:-126px -86px !important;}
/* Set hovers of sub menu buttons to active images */
#masNav:hover,
#shiNav:hover,
#repNav:hover,
#setNav:hover
{background-position:-173px -86px !important;}
After having a good look at this I concluded that my original method of overlaying the border was the best way to achieve this tabbed menu.
HTML:
<nav id="global-nav">
<ul>
<li id="homNav"></li>
<li id="masNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
<li id="shiNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
<li id="repNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
<li id="setNav">#
<div class="subMenuHandle horizontal-sprite">
<div class="bg-noise"></div>
</div>
<div class="subMenu horizontal-sprite">
<div class="bg-noise"></div>
</div>
</li>
</ul>
</nav>
CSS (Sorry for the compression, just my way of formatting):
/* Navigation */
#global-nav {position:absolute;width:460px;height:27px;left:15px;top:43px;}
#global-nav ul {margin:0;padding:0;list-style-type:none;}
#global-nav ul li {position:relative;display:block;width:92px;height:27px;float:left;padding:0;margin-left:8px;z-index:10;background-image:url("http://beta.example.net/_images/_global/sprite.png");background-position:-173px -32px;}
#global-nav ul li:hover {background-position:-173px -59px;}
#global-nav ul li:active {background-position:-173px -86px;}
#global-nav ul li a {display:block;width:92px;height:27px;line-height:27px;text-align:center;color:#fff;font-size:12px;text-shadow:#666 0 -1px 0;}
#global-nav ul li:hover a {color:#666;text-shadow:#fff 0 1px 0;}
#global-nav ul li:active a {color:#666;text-shadow:none;}
/* Set styles for specific navigation buttons */
#homNav {width:47px !important;margin-left:0 !important;margin-right:12px;background-position:-126px -32px !important;}
#homNav a {width:47px !important;}
#homNav:hover {background-position:-126px -59px !important;}
#homNav:active {background-position:-126px -86px !important;}
/* Set hovers of sub menu buttons to active images */
#masNav:hover,
#shiNav:hover,
#repNav:hover,
#setNav:hover
{background-position:-173px -86px !important;}
/* Set the sub menu handles */
#global-nav .subMenuHandle {position:relative;display:none;width:90px;height:12px;margin-top:-1px;border-left:1px solid #666;border-right:1px solid #666;z-index:1000;background-color:#fff;background-repeat:repeat-x;}
/* Set the sub menu container */
#global-nav .subMenu {position:relative;display:none;margin-top:-1px;width:910px;height:180px;border:1px solid #666;z-index:999;background-color:#ddd;background-position:0 -12px;background-repeat:repeat-x;}
/* Set the menu hovers to show sub menus */
#global-nav ul li:hover .subMenuHandle,
#global-nav ul li:hover .subMenu
{display:block;}
/* Set the sub menu container positions */
#masNav .subMenu {margin-left:-83px;}
#shiNav .subMenu {margin-left:-183px;}
#repNav .subMenu {margin-left:-283px;}
#setNav .subMenu {margin-left:-383px;}
/* Set the noise in the menus */
.bg-noise {position:absolute;left:0;top:0;width:100%;height:100%;background:url("https://www.beta.net/_images/_global/bg-noise.png") repeat;}
Related
When hovering over Choose Location the div adv_cities should be displayed and i can navigate the adv_cities menu. What i've tried isn't working.
<div class="header_top_location"> <ul id="city_nav" class="city_nav menu">
<li class="mega">Choose Location
<div class="adv_cities" id="adv_cities" style="display:none">
<ul><li>London</li>
<li>Bristol</li>
<li>Manchester</li>
<li>Kent</li>
</ul>
</div>
</li>
</ul>
</div>
The CSS
.header_top_location .mega > a:hover + .adv_cities, .header_top_location .adv_cities:hover .adv_cities{
display:block !important;
}
.header_top_location .adv_cities {
background-color:#fff
}
.header_top_location .adv_cities ul{
overflow:hidden;
}
.header_top_location .adv_cities li{
float:left;padding:10px;
}
How do i solve this?
The city_nav code is from a plugin and i use on multiple pages, so i don't want to change the code since i use in multiple places.
If all you want on your drop down menu is to hover over one list iten to display the submenu, then you dont necessarily need the inner div and stuff... here is a code snippet for you to work with...
.mega:hover > .adv_cities {
display: block !important;
}
.header_top_location .adv_cities {
background-color: #fff
}
.header_top_location .adv_cities ul {
overflow: hidden;
}
.header_top_location .adv_cities li {
float: left;
padding: 10px;
}
<div class="header_top_location">
<ul id="city_nav" class="city_nav menu">
<li class="mega">Choose Location
<div class="adv_cities" id="adv_cities" style="display:none">
<ul>
<li>London</li>
<li>Bristol</li>
<li>Manchester</li>
<li>Kent</li>
</ul>
</div>
</li>
</ul>
</div>
The only changes I made in css are in the 1st 3 lines... and I removed the extra div that IMO was not needed..
hope this helps
I am trying to put an image behind my header and menu. I set all of the layers above the background image div including all of the menu elements to position:relative;z-index:10; and the div with the background image to position:relative;z-index:0;
you can see my code here: http://wheresuccessblooms.com/wordpress/
I know it has something to do with the menu because when I delete the call to the menu the background image goes to where it should. Not sure what else I need to set the position and z-index to? PULLING MY HAIR OUT. lol Please help.
HTML:
<div class="menu-main-menu-container">
<ul id="menu-main-menu" class="menu">
<li id="menu-item-16" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-16">
HOME
</li>
<li id="menu-item-17" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-17">
ABOUT
</li>
<li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-15">
Contact Us
</li>
</ul>
</div>
<div id="top_slider">
<div id="slider">
<div id="slider_wrap">
</div>
</div>
</div>
CSS: JUST THE MENU AND SLIDER CSS
nav{position:relative;z-index:5;}
div.menu-main-menu-container{position:relative;z-index:5;}
ul#menu-main-menu{position:relative;z-index:5;}
li.menu-item{position:relative;z-index:5;}
#page_nav {width:100%; height:53px;background-color:#f27479;position:relative;z-index:10;}
#page_nav ul { float: left; display: block;position:relative;z-index:5;}
#page_nav ul li { float: left; list-style-type: none; margin-top:20px;border-right:1px solid #ca6064;position:relative;z-index:5;}
#page_nav ul li a { color: #fff; text-decoration: none; font-size: 14px; text-transform: uppercase; font-weight: 700; text-shadow: 0px 1px 0px rgba(0,0,0,.5); padding-left: 20px;position:relative;z-index:5; }
#page_nav ul li a:hover { color: #a2a2a2; position:relative;z-index:5;}
#page_nav ul li.current a,
#page_nav ul li.current a:hover { color: #ba4040; position:relative;z-index:5;}
#top_slider{overflow:hidden;position:relative;z-index:0;left:0px;height:963px;top:-250px; margin:0px auto;
background:url('http://wheresuccessblooms.com/wordpress/wp-content/themes/WhereSuccessBlooms/images/slide_1.jpg') no-repeat top center;}
Your z-index looks like it's working fine to me. There does seem to be a positioning issue though. Set the top_slider div to position:absolute with width:100%. Or you can set position:fixed if you want it to stay put (also needs a width).
Put this line after your </nav> tag
<div style="clear:both"></div>
Got an issue in ie7!, see the image below for how the dropdown menu looks. This works fine in every other browser but in ie7, as soon as you venture outside of the main li 'i.e.: the top link' the menu dissapears. I have already checked setting red boxes around everything and the li element is extending correctly to contain the sub menu but I cannot fix it. Any ideas?
Example of markup:
<nav>
<ul class="clearfix">
<li class="dropdown-link">Top Link
<ul class="clearfix dropdown-holder">
<li>
<div class="arrow"></div>
<div class="dropdown-holder-inner">
<ul class="dropdown">
<li>Link</li>
<li>Link</li>
<li>Linky</li>
<li>Link</li>
<li>Link</li>
<li class="last-child">Link</li>
</ul>
</div>
</li>
</ul>
</li>
</ul>
</nav>
CSS is quite heavy so I have put the Full Code on jsfiddle: http://jsfiddle.net/n2kgX/3/
image: http://i.stack.imgur.com/k24Du.png
I create a sample here: http://jsfiddle.net/jho1086/bbULV/5/, I change the html code and css a little bit because in my opinion container are too many. And I change the HTML5 tag (<nav>) because IE8 and below is not supported with HTML5, unless you have a fixed.
<div id="nav">
<ul class="clearfix sf-menu">
<li class="dropdown-link">Top Link
<div class="clearfix dropdown-holder">
<div class="arrow"></div>
<ul class="dropdown clearfix">
<li>Link</li>
<li>Link</li>
<li>Linky</li>
<li>Link</li>
<li>Link</li>
<li class="last-child">Link</li>
</ul>
</div>
</li>
</ul>
</div>
css
#nav { background:#6B6C6E; width:300px; margin:30px auto 0;}
.sf-menu li{float:left; font:12px/1em 'arial'; position:relative; padding:0 0 5px;}
.sf-menu li a{float:left;padding:12px 10px 5px;color:#fff; text-transform:uppercase;}
.sf-menu .dropdown-holder{
position:absolute;
left:-999em;
width:218px;
top:93%;
}
.sf-menu li:hover .dropdown-holder {left:-999em;}
.sf-menu li:hover .dropdown-holder {left:0;}
.arrow { background:url(arrow.png) no-repeat left top; width:32px; height:8px; position:relative; z-index:2; left:10px;}
.dropdown {
box-shadow:0 0 5px #bec2c8;
background:#fff;
height:100%;
position:relative;
z-index:1;
padding:10px 10px 5px;
}
.sf-menu .dropdown li{text-transform:capitalize; border-bottom:1px solid #ccc;}
.sf-menu .dropdown li.last-child { border:0;}
.sf-menu .dropdown a{
float:left;
padding:5px 0;
width:198px;
color:#333;
}
Hope it helps.
I have a feeling that Your example is overcomplicated.
This is the simplest implementation of nested menu (with hover) I know of:
<ul class="outer">
<li>
<p>TOP MENU</p>
<ul class="inner">
<li>link1</li>
<li>link2
<ul class="inner">
<li>link2.1</li>
</ul>
</li>
<li>link3</li>
</ul>
</li>
</ul>
With a little bit of css:
.outer {
border: 1px solid red;
width: 100px;
}
.inner {
display: none;
}
.inner li {
padding: 0 0 0 10px;
}
.outer li:hover > .inner {
display: block;
}
Tested on IE8 (in IE7 mode with IE7 Standards). Check here: http://jsfiddle.net/BUuyV/11/
Here is what you can do:
<!--[if lte IE 7]>
<style type="text/css">
nav ul li:first-child ul.dropdown-holder{
left: 0px;
top:-4px;
}
</style>
<![endif]-->
Note: For :first-child to work in IE8 and earlier, a <!DOCTYPE> must be declared.
I am currently working with a bottom navigation bar for a test site. The problem is that the navigation bar does not center properly. I have added the .left attribute to keep each block list beside each other. How can I get this bottom navigation bar to center automatically(no matter the amount of lists added)? Example
CSS related to bottom navigation
<style>
.bottomnavControls {
padding-top:10px;
padding-bottom:10px;
padding-right:0;
text-decoration:none;
list-style:none;
}
#footer {
position: absolute;
width: 100%;
bottom: 0;
background: #7a7a7a;
border-bottom: 15px solid #000;
}
.left {
float: left;
}
.right {
float: right;
}
</style>
HTML
<div id="footer">
<div class="bottomNav">
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Home</b></li>
<li>Login</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Category</b></li>
<li>Games</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>About</b></li>
<li>Who We Are</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Links</b></li>
<li>Google</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Other Stuff</b></li>
<li>Stuff</li>
</ul>
</div>
</div>
My current Bottom navigation:
My desired outcome:
Instead of float, you should use display: inline-block here. This way, you can easily center them by putting text-align: center on the container.
.bottomNav { text-align: center; }
.bottomnavControls { display: inline-block; }
and remove left class.
Note: display: inline-block works fine in modern browsers, but it needs a hack in IE7.
I struck up with CSS issue. I have a situation as below
<div>
<ul>
<li> <img src="a.jpg" ></li>
<li> <img src="a.jpg" ></li>
<li> <img src="a.jpg" ></li>
<li> <img src="a.jpg" ></li>
</ul>
</div>
I want to center all my UL tag, but images has to be left align.
I am getting images as center, when I use text-align: center. But, last image in ul is displaying in center which I don't want to display.
Can any one helps me?
Thanks in Advance.
Write like this:
div{text-align:center}
ul{
display:inline-block;
*display:inline;/* for IE7 */
*zoom:1;
text-align:left;
}
try something like this
HTML
<div id="menu">
<ul>
<li><span></span>Add Some Text</li>
<li><span></span>Add Some Text</li>
<li><span></span>Add Some Text</li>
<li><span></span>Add Some Text</li>
<li><span></span>Add Some Text</li>
</ul>
</div>
CSS
#menu li {
clear: left;
}
#menu li a {
padding: 5px 0 0 40px;
display:block;
}
#menu li span {
float: left;
display: block;
height: 32px;
width:32px;
background: url(images/icon.png) no-repeat;
}
Calling the icon image by using a span tag then having control over your text and icon image through your css is the way to go. Of course you can remove the text
Here's the example http://jsfiddle.net/DUjfd/