943,733 Members | Top Members by Rank

Ad:
Apr 26th, 2009
0

Rounded Corners Dropdown

Expand Post »
Hi
I'm stuck wanting to create a dropdown, only supported by CSS. This is my current code:
php Syntax (Toggle Plain Text)
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
  5. <style type="text/css">
  6. html, body {
  7. margin: 0px;
  8. }
  9. body {
  10. background-image: url('img/bottombackground.png');
  11. }
  12. div.topbackground {
  13. width: 100%;
  14. height: 300px;
  15. background-image: url('img/topbackground.png');
  16. }
  17. div.container {
  18. width: 750px;
  19. height: 600px
  20. background-color: #ddd;
  21. margin: -300px auto 0px auto;
  22. }
  23. div.top {
  24. width: 100%;
  25. height: 25px;
  26. }
  27. div.top img.topleft, div.top img.topright {
  28. height: 25px;
  29. width: 11px;
  30. float: left;
  31. }
  32. div.top div.topmiddle {
  33. float: left;
  34. height: 25px;
  35. width: 728px;
  36. text-align: center;
  37. background-image: url('img/top_middle.png');
  38. }
  39. div.top div.topmiddle a:link, div.top div.topmiddle a:visited {
  40. font-family: Arial, Verdana;
  41. font-size: 11px;
  42. color: #7c7c7c;
  43. padding: 0px 15px;
  44. text-decoration: none;
  45. }
  46. div.top div.topmiddle a:hover {
  47. font-family: Arial, Verdana;
  48. font-size: 11px;
  49. color: #5e7381;
  50. text-decoration: underline;
  51. }
  52. div.header {
  53. position: relative;
  54. margin: -30px 0px 0px 10px;
  55. width: 730px;
  56. height: 75px;
  57. }
  58. div.header img {
  59. position: absolute;
  60. }
  61. div.header p {
  62. padding: 15px 0px 0px 20px;
  63. font-family: Arial, Verdana;
  64. font-size: 32px;
  65. font-weight: bold;
  66. color: #5e5e5e;
  67. }
  68. img.arrow {
  69. height: 10px;
  70. width: 10px;
  71. }
  72. img.topleft {
  73. top: 0px;
  74. left: 0px;
  75. }
  76. img.topright {
  77. top: 0px;
  78. right: 0px;
  79. }
  80. img.bottomleft {
  81. bottom: 0px;
  82. left: 0px;
  83. }
  84. img.bottomright {
  85. bottom: 0px;
  86. right: 0px;b
  87. }
  88. img.flowers_top {
  89. height: 45px;
  90. width: 310px;
  91. bottom: 0px;
  92. right: 25px;
  93. }
  94. div.contenttop {
  95. width: 750px;
  96. height: 11px;
  97. }
  98. img.contenttopleft, img.contenttopright{
  99. width: 10px;
  100. height: 11px;
  101. float: left;
  102. }
  103. div.contenttopmiddle {
  104. background-image: url('img/content_topmiddle.png');
  105. width: 730px;
  106. height: 11px;
  107. float: left;
  108. }
  109. div.contentmiddle {
  110. background-image: url('img/content_midmiddle.png');
  111. background-repeat: repeat-x;
  112. width: 708px;
  113. min-height: 211px;
  114. height: auto !important;
  115. height: 211px;
  116. padding: 0px 20px;
  117. color: #5e5e5e;
  118. font-family: Arial, Verdana;
  119. font-size: 12px;
  120. }
  121. div.content {
  122. height: 30px;
  123. background-color: #fff;
  124. border-left: 1px solid #bcbcbc;
  125. border-right: 1px solid #bcbcbc;
  126. min-height: 400px;
  127. height: auto !important;
  128. height: 400px;
  129. }
  130.  
  131. div.contentbottom {
  132. width: 750px;
  133. height: 23px;
  134. }
  135. div.contentbottom img.contentbottomleft, div.contentbottom img.contentbottomright {
  136. height: 23px;
  137. width: 11px;
  138. float: left;
  139. }
  140. div.contentbottom div.contentbottommiddle {
  141. float: left;
  142. height: 23px;
  143. width: 728px;
  144. text-align: center;
  145. background-image: url('img/content_bottommiddle.png');
  146. }
  147. img.flowers_bottom {
  148. margin: 0px 0px 0px 405px;
  149. }
  150.  
  151. /* ================================================================
  152. This copyright notice must be untouched at all times.
  153.  
  154. The original version of this stylesheet and the associated (x)html
  155. is available at http://www.cssplay.co.uk/menus/basic_dd.html
  156. Copyright (c) 2005-2009 Stu Nicholls. All rights reserved.
  157. This stylesheet and the associated (x)html may be modified in any
  158. way to fit your requirements.
  159. =================================================================== */
  160. /* remove the bullets, padding and margins from the lists */
  161. .menu ul{
  162. list-style-type:none;
  163. padding:0;
  164. margin:0;
  165. }
  166. /* make the top level links horizontal and position relative so that we can position the sub level */
  167. .menu li{
  168. float:left;
  169. position:relative;
  170. z-index:100;
  171. }
  172.  
  173. /* use the table to position the dropdown list */
  174. .menu table{
  175. position:absolute;
  176. border-collapse:collapse;
  177. z-index:80;
  178. left:-1px;
  179. top:25px;
  180. }
  181.  
  182. /* style title link */
  183. .menu a.title, .menu a.title:visited {
  184. display: block;
  185. width: 202px;
  186. padding: 5px 0px 5px 5px;
  187. border: 0px;
  188. color: #fff;
  189. background-image: url('img/select_title.png');
  190. background-color: none;
  191. font-size: 11px;
  192. font-family: Arial, Verdana;
  193. text-decoration: none;
  194. }
  195. /* style the links hover */
  196. .menu a.title:hover{
  197. color: #333;
  198. background-image: url('img/select_title_hover.png');
  199. }
  200.  
  201. /* style all the links */
  202. .menu ul li ul li a, .menu ul li ul li a:visited {
  203. display: block;
  204. width: 200px;
  205. padding: 5px 0px 5px 5px;
  206. border-left: 1px solid #5e5e5e;
  207. border-right: 1px solid #5e5e5e;
  208. color: #fff;
  209. background-color: #5e7381;
  210.  
  211. margin: 0px;
  212.  
  213. font-size: 11px;
  214. font-family: Arial, Verdana;
  215. text-decoration: none;
  216. }
  217. /* style the links hover */
  218. .menu ul li ul li a:hover{
  219. color: #333;
  220. background: #6f899a;
  221. }
  222.  
  223. /* hide the sub level links */
  224. .menu ul ul {
  225. visibility:hidden;
  226. position:absolute;
  227. width: 200px;
  228. height: 0px;
  229. }
  230. /* make the sub level visible on hover list or link */
  231. .menu ul li:hover ul,
  232. .menu ul a:hover ul{
  233. visibility:visible;
  234.  
  235. }
  236. </style>
  237. </head>
  238.  
  239. <body>
  240. <div class="topbackground"></div>
  241. <div class="container">
  242. <div class="top">
  243. <img class="topleft" src="img/top_left.png">
  244. <div class="topmiddle"><a href="">Services</a><a href="">Contact</a><a href="">Aanbiedingen</a><a href="">Voorwaarden</a><a href="">MyGIPWebwinkel</a></div>
  245. <img class="topright" src="img/top_right.png">
  246. </div>
  247. <div class="header">
  248. <img class="topleft arrow" src="img/arrow_topleft.png" alt="">
  249. <img class="topright arrow" src="img/arrow_topright.png" alt="">
  250. <img class="bottomleft arrow" src="img/arrow_bottomleft.png" alt="">
  251. <img class="bottomright arrow" src="img/arrow_bottomright.png" alt="">
  252. <img class="flowers_top" src="img/flowers_top.png">
  253. <p>GIPWebwinkel</p>
  254. </div>
  255. <div class="contenttop">
  256. <img class="contenttopleft" src="img/content_topleft.png" alt="">
  257. <div class="contenttopmiddle"></div>
  258. <img class="contenttopright" src="img/content_topright.png" alt="">
  259. </div>
  260. <div class="content">
  261. <div class="contentmiddle">
  262. <div class="menu">
  263. <ul>
  264. <li><a class="title" href="">Producten</a>
  265. <!--[if lte IE 6]><table><tr><td><![endif]-->
  266. <ul>
  267. <li><a href="">Categorie 1</a></li>
  268. <li><a href="">Categorie 2</a></li>
  269. <li><a href="">Categorie 3</a></li>
  270. <li><a href="">Categorie 4</a></li>
  271. <li><a href="">Categorie 5</a></li>
  272. <li><a href="">Speelgoed & Modelbouw</a></li>
  273. <img src="img/select_bottom.png" alt="">
  274. </ul>
  275. <!--[if lte IE 6]></td></tr></table></a><![endif]-->
  276. </li>
  277. </ul>
  278. </div>
  279. </div>
  280. </div>
  281. <div class="contentbottom">
  282. <img class="contentbottomleft" src="img/content_bottomleft.png" alt="">
  283. <div class="contentbottommiddle"></div>
  284. <img class="contentbottomright" src="img/content_bottomright.png" alt="">
  285. </div>
  286. <img class="flowers_bottom" src="img/flowers_bottom.png">
  287. </div>
  288. </body>
  289. </html>

I altered the code copied from a CSS website a bit, and I have now some background images used for the title of the dropdown. I am succesful in changing these when the user hovers over it but I want the image of the dropdown title not to change until the user hovers out of the whole div. Because what now happens is, everthing looks good, until they start going down with their mouse, then the dropdown title appears with 4 rounded corners again. Pictures here for some more explanation:
Normal state:
http://img151.imageshack.us/my.php?image=site1.png

State when hovering the title of the dropdown:
http://img24.imageshack.us/my.php?image=site2a.png

State when hovering an item in the list:
http://img24.imageshack.us/my.php?image=site3p.png
Notice here how the title appears with 4 rounded corners again, I'd like to change that.

Any help would be appreciated;
Thanks
Similar Threads
Reputation Points: 26
Solved Threads: 9
Junior Poster in Training
brechtjah is offline Offline
92 posts
since Nov 2008
Apr 27th, 2009
0

Re: Rounded Corners Dropdown

You are losing hover when the mouse moves away from the object.

This is a job for javascript.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
May 15th, 2009
0

Re: Rounded Corners Dropdown

I have just recently spent a good portion of a week, dissecting and learning to use Stu Nicholl's dropdown/flyout menus myself. and hopefully have the answer to your question.

I had to read the code from like 5 of his menus to understand what every line of code was doing and deleting portions of them one by one to see the changes if any.

On one of them, Stu actually commented the purpose of most of them.

HTML and CSS Syntax (Toggle Plain Text)
  1. /* retain the "rollover" for each sublevel IE7 and Firefox etc */
  2. #menu li:hover > a{background-position:bottom;}

i still do not understand what the ">" does in css like that. and i even took it off and it still works. but it stops working if you take off the "a".

anyway. change the background-position to whatever your rollover set up is, all this does is make it so that in Firefox and IE7, the rollover state remains even when the mouse leaves it while exploring the menu.


this SHOULD solve it. especiallys considering that we got the menu from the same site.


btw. I would love to know how you achieved the rounded corners for the dropdown. how many images did you use for it? 1 for each corner? or 2 (top two corners and bottom two corners)?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sumdude is offline Offline
2 posts
since May 2009
May 17th, 2009
0

Re: Rounded Corners Dropdown

@sumdude you can use many different techniques, but each one will limit some dimension of the html its applied to. You could have an image with four corners (transparent in middle) limiting all sides, 2 corners vertically, limiting the height. You can have 1 image for each side and one for each corner, giving you more flexibility, or other combinations of those.

The > selector in CSS refers to a direct child. I don't think IE 6 supports it.
Reputation Points: 14
Solved Threads: 22
Junior Poster
JugglerDrummer is offline Offline
138 posts
since Apr 2009
May 17th, 2009
0

Re: Rounded Corners Dropdown

i'm currently struggling with making rounded corners, inside a dropdown, made up of lists, while having width set to auto, and wordwrap set to none.

most examples online use divs which i can't easily translate to UL's and LI's.

but that's for another thread I think.

thx for the clarification of the "direct child".
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sumdude is offline Offline
2 posts
since May 2009
Nov 18th, 2011
0
Re: Rounded Corners Dropdown
Please take a look here.
This link contains the HTML select box with rounded corner by using jQuery

http://plugins.jquery.com/plugin-tags/gradient
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ramesh.joshi is offline Offline
1 posts
since Nov 2011
Message:
Previous Thread in HTML and CSS Forum Timeline: Apple type Search Box ?
Next Thread in HTML and CSS Forum Timeline: Commerial web design Issues





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC