Bir web sitesi yaparken göze hoş gelen güzel tasarımların olması gerekiyor. Güzel tasarımlar kullanıcının daha çok hoşuna gidiyor ayrıca daha çok site ile ilgilenmesini sağlıyor. Şimdi sizlere alttaki resimdeki gibi renkli menü butonları yapmayı anlatacağım.
Colorful Accordion With – CSS & jQuery
Öncelikle Demo ve indirme bağlantısını inceleyin. Daha sonra uygulamaya başlayabilirsiniz. Demo’yu ilk etapta görmeniz sizin için daha iyi olucaktır.
Altta css ve html kodları verildi. Şimdi bunları kendi web sitenize uyarlamanız çok basit. Kullandığımız CSS’ye ekleyerek yapmayı göstericem. styles.css dosyanızı açın ve alttaki css kodlarını kendi style.css içine ekleyin. jQuery’i sakın unutmayın. 🙂
Şimdi sitenizin head kısmında şu kodları ekleyin. İndirdiğiniz dosyada bu iki .js dosya mevcuttur.
1 2 3 | < script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></ script > < script type = "text/javascript" src = "jquery.easing.1.3.js" ></ script > < script type = "text/javascript" src = "script.js" ></ script > |
Daha sonra şu şekilde başlık ve alt başlık oluşturucaksınız.
Başlık bu kısımda
1 | <li class= "button" ><a href= "#" class= "green" >Kiwis <span></span></a></li> |
Alt başlık ise bu kısıma
1 2 3 4 5 | <li class= "dropdown" > <ul> <li><a href= "#" >Open Grapes Section</a></li> </ul> </li> |
Ana başlık ve Alt başlık yapılmış hali.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <ul class= "container" > <li class= "menu" > <ul> <li class= "button" ><a href= "#" class= "green" >Kiwis <span></span></a></li> <li class= "dropdown" > <ul> <li><a href= "#" onclick= "$('.button a').eq(2).click();return false;" >Open Grapes Section</a></li> <li><a href= "#" onclick= "$('.dropdown').slideUp('slow');return false;" >Close This Section</a></li> </ul> </li> </ul> </li> |
Style CSS Kodu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | body,h 1 ,h 2 ,h 3 ,p,quote, small ,form,input,ul,li,ol,label{ /* Simple page reset */ margin : 0px ; padding : 0px ; } body{ /* Setting default text color, background and a font stack */ color : #cccccc ; font-size : 13px ; background : #302b23 ; font-family : Arial , Helvetica , sans-serif ; } ul{ margin : 0 ; padding : 0 ; } ul.container{ /* The topmost UL */ width : 240px ; margin : 0 auto ; padding : 50px ; } li{ list-style : none ; text-align : left ; } li.menu{ /* The main list elements */ padding : 5px 0 ; width : 100% ; } li.button a{ /* The section titles */ display : block ; font-family :BPreplay, Arial , Helvetica , sans-serif ; font-size : 21px ; height : 34px ; overflow : hidden ; padding : 10px 20px 0 ; position : relative ; width : 200px ; } li.button a:hover{ /* Removing the inherited underline from the titles */ text-decoration : none ; } li.button a span{ /* This span acts as the right part of the section's background */ height : 44px ; position : absolute ; right : 0 ; top : 0 ; width : 4px ; display : block ; } /* Setting up different styles for each section color */ li.button a. blue { background : url (img/ blue .png) repeat-x top left ; color : #074384 ;} li.button a. blue span{ background : url (img/ blue .png) repeat-x top right ;} li.button a. green { background : url (img/ green .png) repeat-x top left ; color : #436800 ;} li.button a. green span{ background : url (img/ green .png) repeat-x top right ;} li.button a.orange{ background : url (img/orange.png) repeat-x top left ; color : #882e02 ;} li.button a.orange span{ background : url (img/orange.png) repeat-x top right ;} li.button a. red { background : url (img/ red .png) repeat-x top left ; color : #641603 ;} li.button a. red span{ background : url (img/ red .png) repeat-x top right ;} /* The hover effects */ li.button a:hover{ background-position : bottom left ;} li.button a:hover span{ background-position : bottom right ;} .dropdown{ /* The expandable lists */ display : none ; padding-top : 5px ; width : 100% ; } .dropdown li{ /* Each element in the expandable list */ background-color : #373128 ; border : 1px solid #40392C ; color : #CCCCCC ; margin : 5px 0 ; padding : 4px 18px ; } /* The styles below are only necessary for the demo page */ h 1 { font-family : "Myriad Pro" , Arial , Helvetica , sans-serif ; font-size : 36px ; font-weight : normal ; margin-bottom : 15px ; } h 2 { font-family : "Myriad Pro" , Arial , Helvetica , sans-serif ; font-size : 12px ; font-weight : normal ; padding-right : 140px ; right : 0 ; text-align : right ; text-transform : uppercase ; top : 15px ; } .clear{ clear : both ; } #main{ /* The main container */ margin : 15px auto ; text-align : center ; width : 920px ; position : relative ; } a, a:visited { color : #0196e3 ; text-decoration : none ; outline : none ; } a:hover{ text-decoration : underline ; } p{ /* The tut info on the bottom of the page */ padding : 10px ; text-align : center ; } |
HTML Kodu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | < div id = "main" > < h1 >Colorful Content Accordion, CSS & jQuery</ h1 > < h2 >View the < a href = "http://tutorialzine.com/2009/12/colorful-content-accordion-css-jquery/" >original tutorial »</ a ></ h2 > < ul class = "container" > < li class = "menu" > < ul > < li class = "button" >< a href = "#" class = "green" >Kiwis < span ></ span ></ a ></ li > < li class = "dropdown" > < ul > < li >< a href = "#" onclick = "$('.button a').eq(2).click();return false;" >Open Grapes Section</ a ></ li > < li >< a href = "#" onclick = "$('.dropdown').slideUp('slow');return false;" >Close This Section</ a ></ li > </ ul > </ li > </ ul > </ li > < li class = "menu" > < ul > < li class = "button" >< a href = "#" class = "orange" >Oranges < span ></ span ></ a ></ li > < li class = "dropdown" > < ul > < li >< a href = "#" onclick = "$('.button a:last').click();return false;" >Open Last Section</ a ></ li > </ ul > </ li > </ ul > </ li > < li class = "menu" > < ul > < li class = "button" >< a href = "#" class = "blue" >Grapes < span ></ span ></ a ></ li > < li class = "dropdown" > < ul > < li >Text label 1</ li > < li >Text label 2</ li > </ ul > </ li > </ ul > </ li > < li class = "menu" > < ul > < li class = "button" >< a href = "#" class = "red" >Strawberries < span ></ span ></ a ></ li > < li class = "dropdown" > < ul > < li >< a href = "http://www.flickr.com/search/?w=all&q=strawberries&m=text" >Photo Stream</ a ></ li > </ ul > </ li > </ ul > </ li > </ ul > |