Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2012, 09:17 AM   PM User | #1
jpt145
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
jpt145 is an unknown quantity at this point
Question Really Cool CSS Navigation w/o Javascript

See www.Hilton.com

Anybody have know how this CSS full screen drop down element is coded>

At www.hilton.com on the homepage its in the middle of the screen, once you click through it goes to the top.

Im trying to figure out how they did this using only CSS. I've done CSS only drop down menus before, but they were never full screen width like this, and in all my attempts, the child elements align under the parent LI element.

They have that too technically, but I can figure out how to make the child elements background go 100% screen width yet.

This is a really cool menu, if anyboby can point me in the right direction, when I code it I'll post it here and give you credit.

Thanks

JT
jpt145 is offline   Reply With Quote
Old 12-11-2012, 10:04 AM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,697
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
First of all: The dropdown functionality doesn’t work without JavaScript, so it’s not a CSS-only dropdown.
Layout wise there are several ways to do this. One would be to have a regular list for the links and then some sections below which would represent the dropdown items, all in one container that is 100% wide and has a blue background. On mouseover you would hide and show the items which will push the bottom edge of the container down and there you have your special thing.

A true CSS-only solution would be to put the dropdown items into the list items of the menu and position them absolutely but without positioning the parent list items relative, so the dropdown items would be positioned relative to the edge of the overall container, not to the list items. Then make them 100% wide and give them a blue background and there you go.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
jpt145 (12-11-2012)
Old 12-11-2012, 10:10 AM   PM User | #3
jpt145
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
jpt145 is an unknown quantity at this point
Smile

Thanks, Im working on it and will post the result wen Im done. Thanks alot really.
jpt145 is offline   Reply With Quote
Old 12-11-2012, 12:17 PM   PM User | #4
jpt145
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
jpt145 is an unknown quantity at this point
I've got the Pure CSS version working. Only its difficult to center the drop down items because the centering is established by the root list -the main menu. Since the Sub menu is positioned absolute, its removed from positioning relative to the parent, and thus a pain to center.

I'd need to nest the sub list all over again and that might pose other problems.

Traditional javascript maniplulating elements is a better way to do this I think.

Looks like thats what you were thinking too ?

JT
jpt145 is offline   Reply With Quote
Old 12-11-2012, 02:15 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,697
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
You can put another container inside and center that one. Here is a simple mock-up – and it’s still only one way of a few to do it:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<style type="text/css">
		body, #nav {
			margin: 0;
			padding: 0;
			list-style: none;
		}
		#header {background: olive;}
		#nav {
			text-align: center;
			position: relative;
			background: green;
		}
		#nav li {
			display: inline-block;
			background: lime;
		}
		#nav li a {
			display: block;
			padding: 5px 10px;
		}
		#nav li .container {
			position: absolute;
			left: 0;
			width: 100%;
			background: green;
			text-align: left;
			display: none;
		}
		#nav li:hover .container {display: block;}
		#nav li .container > div {
			width: 300px;
			margin: auto;
			background: aqua;
		}
		</style>
	</head>
	<body>
		<div id="container">
			<div id="header">
				<ul id="nav">
					<li>
						<a href="">link 1</a>
						<div class="container">
							<div>
							hello world
							</div>
						</div>
					</li>
					<li>
						<a href="">link 2</a>
						<div class="container">
							<div>
							I’m centered
							</div>
						</div>
					</li>
					<li>
						<a href="">link 3</a>
						<div class="container">
							<div>
							me too!
							</div>
						</div>
					</li>
				</ul>
			</div>
		</div>
	</body>
</html>
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:24 AM.


Advertisement
Log in to turn off these ads.