Category: CSS


I’m using the AVH Extended Categories plugin to control the display of categories in a new blog, and was having problems getting it to show the hierarchy in a user-friendly way. This code below will do the trick for up to 2 levels of child categories, the background-position is for the bullet image already included in the main list styling. This isn’t really AVH specific, it can be used for any vertical menu, and the class ‘children’ is something WordPress automatically applies to all the subpages of a given parent page.

1st child level:
.sidebar-box ul.children li a:link,
.sidebar-box ul.children li a:visited,
.sidebar-box ul.children li a:active {
width: 208px;
padding: 5px 10px 5px 55px;
background-position: 30px 10px;
}

2nd child level:
.sidebar-box ul.children ul li a:link,
.sidebar-box ul.children ul li a:visited,
.sidebar-box ul.children ul li a:active {
width: 188px;
padding: 5px 10px 5px 75px;
background-position: 50px 10px;
}

Here’s the styled nested menu in action (left sidebar).

sidebarwidgetApplying CSS styles to a particular widget in WordPress (2.9.1 is my current version at the time of this posting) is surprisingly easy.

I’m using the WPNG Calendar widget to pull in events from Google Calendar. I wanted to apply special styling to it that matches the styling of one other key widget on the home page, so here’s what I did. I found the id for the calendar widget (wpng-calendar) and then went into my CSS file to add this:

div#wpng-calendar {
position: relative;
width: 301px;
padding: 0 0 5px 0;
margin: 12px auto 10px;
background: url(../images/teaser.png) no-repeat bottom left;
}
div#wpng-calendar h3 {
position: relative;
top: 0;
margin: 0;
padding: 0.5em 0 0 1em;
background: url(../images/teaser-top.jpg) no-repeat top left;
}
div#wpng-cal-widget-events {
padding: 0.5em 1em 1em 1.2em;
}
div#wpng-cal-widget-events ul {
margin: 0 1em 0 1.5em;
list-style-type: disc;
}
div#wpng-cal-widget-events ul li {
padding: 0 0 0.2em 0;
line-height: 1.4em;
font-size: 13px;
}

Easy, and I now have a nicely-styled events listing in my sidebar.

I have a large Joomla site rapidly approaching launch-readiness, and I have a lot to do on it this weekend – finalizing the CSS styles, checking through about 70 pages of content to make sure nothing stands out as being wonky, and creating a few forms.

Then I’ll need to do some styling of the SOBI2 component, which I’ve done before, and is thankfully quite easy.

And then, some final testing and tweaking of SOBI2 and making a list for my subs of little things I see along the way. We’re getting close.

A nice article with tips for improving the efficiency of front-end development.

It’s one of those days. I missed my meetup group this morning due to lack of advanced planning (kept plugging away at the CSS sliding doors menu I’m working on rather than getting ready to go in time); a second meeting was postponed because I don’t have the WordPress blog setup on a client’s site yet; and a third meeting was canceled.

So now I’m almost done with my sliding doors menu. My wood floor client decided they’d rather have tabs than text links, and I found a nice example at Stu Nicholl’s site. I like his style, but not the colors, so I’m recreating his three images with my own in colors more fitting to the client’s woodsy green and tan palette.

I kind of stumbled into this today and it’s working nicely for me in FF, IE7, Safari and Opera.

Here’s the example page.

Step-by-step:

1. Set up a simple unordered list with multiple levels (mine has two, but you could use more with a little work).

2. Here’s the HTML for the menu section (refer to the example for the full code). Note that you need to put an ID on each of the ul li ul’s.

<div class=”nav”>
<ul>
<li><a href=”expanding_menu_problems.html”>Your Problems</a>
<ul id=”menu-problems”>
<li>Issue 1</li>
<li>Issue 2</li>
<li>Issue 3</li>
</ul>
</li>
<li><a href=”expanding_menu_solutions.html”>Our Solutions</a>
<ul id=”menu-solutions”>
<li>Solution 1</li>
<li>Solution 2</li>
<li>Solution 3</li>
</ul>
</li>
<li><a href=”expanding_menu_studies.html”>Our Case Studies</a>
<ul id=”menu-studies”>
<li>Case Study 1</li>
<li>Case Study 2</li>
<li>Case Study 3</li>
</ul>
</li>
</ul>
</div>

3. Style the list any way you like, but the important parts to remember are to (1) give all the ul li ul’s display: none; and (2) then add in, one for each ul li ul, something like this:

#problems #menu-problems {
display: list-item;
}

4. Now on the body tag, add an ID: ‘body id=”problems”‘ for the first page. On each page, do the same for each different ul li ul you’ve created.

That’s it. When you visit each page, the CSS in step 3 will toggle the display of the ul li ul associated with the body tag and only that one’s contents will display.

Please if you have any problems with this, ask. I just typed this up quickly because, of course, I’m on a deadline.

© 2012 position: relative; All rights reserved. Powered by WordPress.