Have you thought about remaking your website header section? As you know – this is the most important section of any website. First of all, all visitors are paying attention on this part of the site. And, the more clean and tidy it is, the better opinions on your site get visitors. In our today’s article I will show you how to create high-quality and modern header for your site. This header will include a logo, several links in the upper right corner, drop-down navigation menu and search form.
Before we start, I would like to show you what exactly we are going to buid:
[sociallocker]
[/sociallocker]
Now, let’s download the sources and start coding !
Step 1. HTML
In the most beginning, we have to define our header with all mentioned elements:
index.html
03 |
< a href = "#" id = "logo" >< img src = "images/logo.png" ></ a > |
06 |
< a href = "#" >About us</ a > |
08 |
< a href = "#" >Contact Us</ a > |
14 |
< li class = "active" >< a href = "index.php" >Home</ a > |
16 |
< li >< a href = "#" >< span class = "icon elem1" ></ span >Facebook</ a ></ li > |
17 |
< li >< a href = "#" >< span class = "icon elem2" ></ span >Google</ a ></ li > |
18 |
< li >< a href = "#" >< span class = "icon elem3" ></ span >RSS</ a ></ li > |
19 |
< li >< a href = "#" >< span class = "icon elem4" ></ span >Skype</ a ></ li > |
20 |
< li >< a href = "#" >< span class = "icon elem5" ></ span >Stumbleupon</ a ></ li > |
23 |
< li >< a href = "#" >Faces</ a > |
25 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 1</ a ></ li > |
26 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 2</ a ></ li > |
27 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 3</ a ></ li > |
28 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 4</ a ></ li > |
29 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 5</ a ></ li > |
32 |
< li >< a href = "#" >Clubs</ a > |
34 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 1</ a ></ li > |
35 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 2</ a ></ li > |
36 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 3</ a ></ li > |
37 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 4</ a ></ li > |
38 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 5</ a ></ li > |
41 |
< li >< a href = "#" >Photos</ a > |
43 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 1</ a ></ li > |
44 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 2</ a ></ li > |
45 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 3</ a ></ li > |
46 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 4</ a ></ li > |
47 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 5</ a ></ li > |
50 |
< li >< a href = "#" >Videos</ a ></ li > |
51 |
< li >< a href = "#" >Games</ a ></ li > |
52 |
< li >< a href = "#" >Blog</ a > |
54 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 1</ a ></ li > |
55 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 2</ a ></ li > |
56 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 3</ a ></ li > |
57 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 4</ a ></ li > |
58 |
< li >< a href = "#" >< span class = "icon elem0" ></ span >menu element 5</ a ></ li > |
61 |
< li >< a href = "#" >Classifieds</ a ></ li > |
66 |
< form role = "search" method = "get" > |
67 |
< input type = "text" placeholder = "search..." name = "s" value = "" autocomplete = "off" /> |
Everything should be easy to understand. This is quite usual UL-LI based menu plus easy search form
Step 2. CSS
css/main.css
Now, our main step – we have to stylize our prepared header. First of all – general styles for header itself, upper right corner links and logo:
04 |
border-color :rgba( 0 , 0 , 0 , 0.1 ); |
05 |
border-bottom-color :rgba( 0 , 0 , 0 , 0.2 ); |
08 |
background :-webkit-linear-gradient( top , #f7f7f7 , #f4f4f4 ); |
09 |
background :-moz-linear-gradient( top , #f7f7f7 , #f4f4f4 ); |
10 |
background :-o-linear-gradient( top , #f7f7f7 , #f4f4f4 ); |
11 |
background :linear-gradient(to bottom , #f7f7f7 , #f4f4f4 ); |
12 |
background- clip :padding-box; |
13 |
border-radius: 0 0 5px 5px ; |
36 |
text-shadow : 0 1px 0 #FFFFFF ; |
39 |
border-left : 1px solid #DEDEDE ; |
42 |
text-decoration : none ; |
44 |
#links a:first-child { |
Now, we have to define styles for our drop down navigation menu (pure CSS3), here is it:
03 |
background : -webkit-linear-gradient( #f6f6f6 , #e9eaea ) repeat scroll 0 0 transparent ; |
04 |
background : -moz-linear-gradient( #f6f6f6 , #e9eaea ) repeat scroll 0 0 transparent ; |
05 |
background : linear-gradient( #f6f6f6 , #e9eaea ) repeat scroll 0 0 transparent ; |
06 |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr= '#f6f6f6' , endColorstr= '#e9eaea' ,GradientType= 0 ); |
07 |
border-radius: 0 0 4px 4px ; |
08 |
border-top : 1px solid #D1D1D1 ; |
09 |
box-shadow: -1px 1px 0 rgba( 255 , 255 , 255 , 0.8 ) inset ; |
18 |
text-decoration : none ; |
30 |
border-color : #D1D1D1 ; |
33 |
border-width : 0 1px 0 0 ; |
34 |
box-shadow: -1px 0 0 rgba( 255 , 255 , 255 , 0.8 ) inset , 1px 0 0 rgba( 255 , 255 , 255 , 0.8 ) inset ; |
40 |
padding : 11px 15px 10px ; |
41 |
text-shadow : 0 1px 0 #FFFFFF ; |
44 |
background : -webkit-linear-gradient( #efefef , #e9eaea ) repeat scroll 0 0 transparent ; |
45 |
background : -moz-linear-gradient( #efefef , #e9eaea ) repeat scroll 0 0 transparent ; |
46 |
background : linear-gradient( #efefef , #e9eaea ) repeat scroll 0 0 transparent ; |
47 |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr= '#efefef' , endColorstr= '#e9eaea' ,GradientType= 0 ); |
49 |
#menu > ul > li.active > a { |
50 |
background : -webkit-linear-gradient( #55A6F1 , #3F96E5 ) repeat scroll 0 0 transparent ; |
51 |
background : -moz-linear-gradient( #55A6F1 , #3F96E5 ) repeat scroll 0 0 transparent ; |
52 |
background : linear-gradient( #55A6F1 , #3F96E5 ) repeat scroll 0 0 transparent ; |
53 |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr= '#55A6F1' , endColorstr= '#3F96E5' ,GradientType= 0 ); |
54 |
border-bottom : 1px solid #2D81CC ; |
55 |
border-top : 1px solid #4791D6 ; |
56 |
box-shadow: -1px 0 0 #55A6F1 inset , 1px 0 0 #55A6F1 inset ; |
58 |
margin : -1px 0 -1px -1px ; |
59 |
text-shadow : 0 -1px 0 rgba( 0 , 0 , 0 , 0.3 ); |
61 |
#menu > ul > li.active > a:hover { |
62 |
background : -webkit-linear-gradient( #499FEE , #3F96E5 ) repeat scroll 0 0 transparent ; |
63 |
background : -moz-linear-gradient( #499FEE , #3F96E5 ) repeat scroll 0 0 transparent ; |
64 |
background : linear-gradient( #499FEE , #3F96E5 ) repeat scroll 0 0 transparent ; |
65 |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr= '#499FEE' , endColorstr= '#3F96E5' ,GradientType= 0 ); |
67 |
#menu > ul > li:first-child > a { |
68 |
border-radius: 0 0 0 5px ; |
Finally, all we need is to realize – drop-down behavior. I prepared next styles which allow us to slide smoothly down popup menu:
003 |
background : -webkit-linear-gradient( #F7F7F7 , #F4F4F4 ) repeat scroll 0 0 padding-box transparent ; |
004 |
background : -moz-linear-gradient( #F7F7F7 , #F4F4F4 ) repeat scroll 0 0 padding-box transparent ; |
005 |
background : linear-gradient( #F7F7F7 , #F4F4F4 ) repeat scroll 0 0 padding-box transparent ; |
006 |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr= '#F7F7F7' , endColorstr= '#F4F4F4' ,GradientType= 0 ); |
007 |
border : 1px solid rgba( 0 , 0 , 0 , 0.1 ); |
008 |
border-radius: 5px 5px 5px 5px ; |
009 |
box-shadow: 0 1px 0 #FFFFFF inset ; |
019 |
-webkit-transition: all . 5 s; |
020 |
-moz-transition: all . 5 s; |
021 |
-ms-transition: all . 5 s; |
022 |
-o-transition: all . 5 s; |
025 |
#menu ul li:hover ul { |
032 |
border-right-width : 0 ; |
033 |
border-top : 1px solid #D1D1D1 ; |
034 |
box-shadow: 0 1px 0 #FFFFFF inset ; |
039 |
text-shadow : 0 1px 0 #FFFFFF ; |
041 |
#menu ul ul li:first-child a { |
044 |
#menu ul ul a . icon { |
045 |
background-position : 50% 50% ; |
046 |
background-repeat : no-repeat ; |
053 |
#menu ul ul a . icon .elem 0 { |
054 |
background-image : url ( "../images/elem.png" ); |
056 |
#menu ul ul a . icon .elem 1 { |
057 |
background-image : url ( "../images/fb.png" ); |
059 |
#menu ul ul a . icon .elem 2 { |
060 |
background-image : url ( "../images/go.png" ); |
062 |
#menu ul ul a . icon .elem 3 { |
063 |
background-image : url ( "../images/rs.png" ); |
065 |
#menu ul ul a . icon .elem 4 { |
066 |
background-image : url ( "../images/sk.png" ); |
068 |
#menu ul ul a . icon .elem 5 { |
069 |
background-image : url ( "../images/su.png" ); |
073 |
margin : 13px 10px 0 0 ; |
077 |
background : url ( "../images/search.gif" ) no-repeat scroll 5% 50% transparent ; |
078 |
border : 1px solid #CCCCCC ; |
079 |
border-radius: 3px 3px 3px 3px ; |
080 |
box-shadow: 0 1px 0 rgba( 0 , 0 , 0 , 0.05 ) inset , 0 1px 0 #FFFFFF ; |
087 |
background-color : #F9F9F9 ; |
093 |
text-shadow : 0 1px 0 #FFFFFF ; |
094 |
background : none repeat scroll 0 0 transparent ; |
097 |
outline : medium none ; |
101 |
#search form input.placeholder, #search form input:-moz-placeholder { |
Conclusion
That is all for today. We have just prepared a really nice looking and neat header block with own navigation menu. I’m sure that this material will be very useful for everybody. Good luck and welcome back