[Pro] CSS Menus - Rounded Corners & Shadow

If you Control-click (or right-click) on the main menu, you should see an option called Inspect Element in the contextual menu. In the dialog that opens, you should be able to see the style rules currently applied to that element (and to navigate through the tree of elements that makes up the menu). Once you find the right tag name and classnames applied to it, you should be able to modify these style rules (or make new ones) to do just that.

If you don’t see this option in your contextual menu, then you might not have enabled the Developer menu in Safari or installed Firebug in Firefox. (Both do roughly the same things.) For Safari, hunt around the preferences. For Firefox, go to http://getfirebug.com

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walt,

“Once you find the right tag name and classnames applied to it, you should be able to modify these style rules (or make new ones) to do just that.”

Not sure what I’m looking for or what to do with it when I find it! Can you clarify?

I am working from Joe’s download above.
Thanks Jan


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

In the code you got from Joe, there’s a part that looks like this:

ul.sub li.fwLastChild > a

This is the CSS selector, which is the part of a rule outside of the
curly braces which tells the CSS system what elements to select and
apply the contents of the curly braces (the rules) to.

What you will need to do is find out what classname or ID is applied
to the main element that creates your menu bar. You will discover this
using the tools I listed earlier. As you move from element to element
in the Web Inspector (Safari) or the Firebug HTML tab (Firefox), the
corresponding element will be highlighted on screen, so you can see
what’s what.

Let’s say your main menu was similar to James’, then your main menu ID
would be fwNav1. So if you wanted to create the curved ends, you would
simply make a new CSS style that looked like this:

#fwNav1 {
      -webkit-border-radius: 7px;
       -moz-border-radius: 7px;
        border-radius: 7px;
}

The # sign (octothorp) means that this is an ID selector. If we were
using one of the classnames applied to that element, like Centered,
then you would write the selector as .Centered instead. (But that
would probably apply to more things than you intended, as IDs are
absolutely page-unique, and classnames may be re-used over the page,
and applied to lots of different elements on the same page, so
possibly not only the ones you intend.

You’d need to experiment with this selector, though, because of the
problems noted earlier about the contents of the list not being
“clipped” by curved borders on the parent element. You would probably
have to do some more Control-clicking to discover the exact
combination of elements to add to your selector in order to get
everything lined up so you have curved ends on your menu.

Walter

On Jun 5, 2010, at 7:19 PM, jan smoot wrote:

Walt,

“Once you find the right tag name and classnames applied to it, you
should be able to modify these style rules (or make new ones) to do
just that.”

Not sure what I’m looking for or what to do with it when I find it!
Can you clarify?

I am working from Joe’s download above.
Thanks Jan


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Okay. This is sorta greekish to me, but I put this code in the page markup with Joe’s CSS code. It doesn’t render the main menu any differently - no corners. When I inspect the menu in Safari, I see CSS, such as, -webkit-border-bottom-left-radius: 7px 7px; which I can click on and off, but there seem to be no visual effect.

Then, I added the shadow CSS code to #fwNav1 which renders nicely.
-webkit-box-shadow: #505050 3px 3px 16px;
-moz-box-shadow: #505050 3px 3px 16px;
box-shadow: #505050 3px 3px 16px;

I then went back and tried just rounding the lower left and lower right corners. Again, the CSS code seemed to have no visual effect.

These attributes seem so basically desirable to the CSS menu - couldn’t they be added to the CSS menu action?

Thanks again. Jan


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Can you post a link to the test page?

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

http://www.buchanandesign.net/rctest/


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Jan, I just viewed your URL. I see shadow and rounded bottom corners in Safari 4 Mac. Clearly, you must be viewing it in an incompatible browser.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

He’s talking about also rounding the main menu itself.

Jan, try adding the following to your CSS. Do this in a separate selector, leave everything you already have in place.

#fwNav1 li.fwFirstChild, #fwNav1 li.fwFirstChild a {
     -webkit-border-bottom-left-radius: 7px;
     -moz-border-radius-bottomleft: 7px;
     border-bottom-left-radius: 7px;
}
#fwNav1 li.fwLastChild, #fwNav1 li.fwLastChild a {
     -webkit-border-bottom-right-radius: 7px;
     -moz-border-radius-bottomright: 7px;
     border-bottom-right-radius: 7px;
}

The issue is that the UL cannot seem to “clip” the LI and A tags nested inside it to round these corners.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Curious. I am using Safari 4.0.4 on a MacBook with Snow Leopard. I see shadow, but no rounded corners. I see same with Firefox 3.6.3.

Hummm.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walt,

Okay. That did it for me. I actually want all four corners rounded, so I modified to:

#fwNav1 li.fwFirstChild, #fwNav1 li.fwFirstChild a {
-webkit-border-bottom-left-radius: 7px;
-moz-border-radius-bottomleft: 7px;
border-bottom-left-radius: 7px;
-webkit-border-top-left-radius: 7px;
-moz-border-radius-topleft: 7px;
border-top-left-radius: 7px;
}
#fwNav1 li.fwLastChild, #fwNav1 li.fwLastChild a {
-webkit-border-bottom-right-radius: 7px;
-moz-border-radius-bottomright: 7px;
border-bottom-right-radius: 7px;
-webkit-border-top-right-radius: 7px;
-moz-border-radius-topright: 7px;
border-top-right-radius: 7px;
}

Thanks a lot!!! From all of us. Wish you sat at the next desk.

Jan


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You’re welcome!

Walter

On Jun 7, 2010, at 12:51 AM, jan smoot wrote:

Walt,

Okay. That did it for me. I actually want all four corners rounded,
so I modified to:

#fwNav1 li.fwFirstChild, #fwNav1 li.fwFirstChild a {
-webkit-border-bottom-left-radius: 7px;
-moz-border-radius-bottomleft: 7px;
border-bottom-left-radius: 7px;
-webkit-border-top-left-radius: 7px;
-moz-border-radius-topleft: 7px;
border-top-left-radius: 7px;
}
#fwNav1 li.fwLastChild, #fwNav1 li.fwLastChild a {
-webkit-border-bottom-right-radius: 7px;
-moz-border-radius-bottomright: 7px;
border-bottom-right-radius: 7px;
-webkit-border-top-right-radius: 7px;
-moz-border-radius-topright: 7px;
border-top-right-radius: 7px;
}

Thanks a lot!!! From all of us. Wish you sat at the next desk.

Jan


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Okay folks, I’ve tweaked the code as best a “brain-dead-to-code” man can. Here are two sets of Page Markup code for you:

Opaque Menus

<style type="text/css">
<!--
#fwNav1 .sub {
-webkit-box-shadow: #333333 3px 4px 12px; 
-moz-box-shadow: #333333 3px 4px 12px; 
box-shadow: #333333 3px 4px 12px; 
}
#fwNav1 ul.sub,
#fwNav1 ul.sub li.fwLastChild,
#fwNav1 ul.sub li.fwLastChild a
{
	-webkit-border-bottom-right-radius: 7px;
	-webkit-border-bottom-left-radius: 7px;
	-moz-border-radius-bottomright: 7px;
	-moz-border-radius-bottomleft: 7px;
	border-bottom-right-radius: 7px;
	border-bottom-left-radius: 7px;
    background: #82878D;
}
-->
</style>

<style type="text/css">
<!--
#fwNav1 ul.sub .sub,
#fwNav1 ul.sub .sub li.fwFirstChild > a,
#fwNav1 ul.sub .sub li.fwFirstChild,
#fwNav1 ul.sub .sub li.fwFirstChild > span a
 {
       -webkit-border-top-right-radius: 7px;
       -moz-border-radius-topright: 7px;
       border-top-right-radius: 7px;
}
-->
</style>

Semi-Transparent Menus

<style type="text/css">
<!--
#fwNav1 .sub {
-webkit-box-shadow: #333333 3px 4px 12px; 
-moz-box-shadow: #333333 3px 4px 12px; 
box-shadow: #333333 3px 4px 12px; 
}
#fwNav1 ul.sub,
#fwNav1 ul.sub li.fwLastChild
{
	-webkit-border-bottom-right-radius: 7px;
	-webkit-border-bottom-left-radius: 7px;
	-moz-border-radius-bottomright: 7px;
	-moz-border-radius-bottomleft: 7px;
	border-bottom-right-radius: 7px;
	border-bottom-left-radius: 7px;
}
#fwNav1 ul.sub li.fwLastChild a
{
	-webkit-border-bottom-right-radius: 6px;
	-webkit-border-bottom-left-radius: 6px;
	-moz-border-radius-bottomright: 6px;
	-moz-border-radius-bottomleft: 6px;
	border-bottom-right-radius: 6px;
	border-bottom-left-radius: 6px;
}
#fwNav1 .fwNavItem .sub .fwNavItem a {
    background: rgba(130, 135, 141, 0.97);
}
-->
</style>

<style type="text/css">
<!--
#fwNav1 ul.sub .sub,
#fwNav1 ul.sub .sub li.fwFirstChild > a,
#fwNav1 ul.sub .sub li.fwFirstChild
 {
       -webkit-border-top-right-radius: 7px;
       -moz-border-radius-topright: 7px;
       border-top-right-radius: 7px;
}
#fwNav1 ul.sub .sub li.fwFirstChild > span a
{
       -webkit-border-top-right-radius: 6px;
       -moz-border-radius-topright: 6px;
       border-top-right-radius: 6px;
}
-->
</style>

<!--[if IE]>
<style type="text/css">
<!--
#fwNav1 ul.sub, #fwNav1 ul.sub li.fwLastChild, #fwNav1 ul.sub li.fwLastChild a {
       background: #82878D;
}
-->
</style>
<![endif]-->

NOTES:

  1. If using Opaque Menus, set your menu “Background” color in the CSS Menus action. In my case, the color chosen in the CSS Menus action was 82878D, which is why you see that in my code above.

  2. If using Semi-Transparent, you need to be sure to set “Background” in the CSS Menu action to “None.”


Despite all the tweaks that Walter and Joe so kindly offered here, I was still not completely satisfied with the curved corner areas when the menus were semi-transparent. The reason is, despite all the heavy duty code to refine the curves, you can still see some artifacts in those curves, which is influenced by underlying content. Having good vision myself, I consider this quite unsightly and unacceptable on my site.

So after all this effort, I ultimately when back to solid menu colors (the first code block above), and it works very nicely for me.

Of course, your mileage will vary as you experiment with different colors and shades of color, with and without a menu border But if you go with the same gray tones and thin border as I used, you’ll probably come to the same conclusions as I did.


To conclude I would also like to mention Fred Kylander. This kind soul has a good “Code Head” on his shoulders and he has offered me a significant amount of advice off-list. In his most recent correspondence, he alerted me to the fact that OS X menus use padding, which is something the code blocks above do not include. Here are Fred’s words exactly…

Look at how Apple handles the top right hand corner
curving problem: they use top and bottom padding on the
parent ul to make sure the corner curve isn't covered by
the li element's (or a element's as the case may be)
background colour change. Simple, elegant and smart
way to solve the problem. Might be worth considering -
if nothing else then to save you from having to write
really long style blocks, one block for each menu
level...

And Fred gives some specifics here…

To implement it you'd need to add something like the
following for your ul styles (and note that it should
**only** be applied to submenu ul styles, not li styles
or a styles or span styles).

#fwNavItem1 ul {padding-top:5px; padding-bottom:5px;}
#fwNavItem2 ul {padding-top:5px; padding-bottom:5px;}
etc...

The padding should propagate to all ul elements within
#fwNavItem1, #fwNavItem2 and so on. If it doesn't, you'd
have to get more specific with the styling, something in
the order of:
#fwNavItem1 ul.sub,
#fwNavItem1 ul.sub ul,
#fwNavItem1 ul.sub ul ul,
#fwNavItem1 ul.sub ul ul ul {padding-top:5px; padding-bottom:5px;}

This is untested though -with regards to your specific
menu construction- so even if it is sound as CSS goes,
there's no guarantee it'll work off the bat in your menu.

The padding value is of course just an example. In the
Mac OS X menu it appears to be set to just cover the
corner curvature, which if you have a 9px curve would
require around 4.5px padding but since decimal pixel
values don't really work well in CSS we set it to the
nearest whole value that is greater than the decimal
value (5px). So you'll need to experiment with the
padding value to get it exactly right, if you indeed use it
at all.

I experimented a bit with Fred’s suggestions but couldn’t get it to work well. Then again, I am brain-dead-to-code. Perhaps some of you will fair better than I.

Best wishes.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I just don’t get it. I’ve watched the video ‘Moment’ about how to create a Blog Template…
http://www.softpress.com/support/tutorials/HQ/13/
OK, some dummy text is displayed when any Actions > Blogger Actions boxes are placed on the page.
But that does not describe how I get the REAL text into that box?
Can someone please tell me?

Thanks,
Adrian
http://www.clubtype.co.uk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’ve modified the markdown to style the sub menu with four rounded corners and applied it to a test page.

The code reads:

<style type="text/css">
<!--
.sub {
-webkit-box-shadow: #555 0px 2px 4px;
-moz-box-shadow: #555 0px 2px 4px;
box-shadow: #555 0px 2px 4px;
}
#sub-nav  ul.sub, #sub-nav ul.sub li.fwLastChild, #sub-nav ul.sub li.fwLastChild a {
	-webkit-border-radius: 8px;
	-moz-border-radius: 8px;
	border-radius: 8px;
	background: #FFF;
}
-->
</style>

However, I’m getting strange result; the top rounded corners are only applied to the last menu item, see:

http://tone-alone.com/dev/menu/

I also included a sketch of the menu design I’m trying to achieve with this technique …


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Anthony,

Have a look at the HTML on my site here:

—James Wages


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options