three4one design

design is the face of your business

Tutorial: Easy Conditional CSS in WordPress Headway theme

I bet that caught your attention! Anyone who’s played with CSS knows it does not have conditional statements.

But CSS, in a sense, is naturally conditional. By giving an element on a page a class, you can mimic conditionality.

WordPress has some very useful built in classes that can be used in that conditional sense.

Most useful,are those are called in the body tag and include: home, blog, single, archive, category and  page

The condition (i.e. what type of page) has already been identified and applied by WordPress. It’s then just a simple matter for you to use it.

For example, mabe you want a different header image for each page type but the same for all post type pages. So you’d set a default image and then over-ride it on the required pages. Such as:

body.custom.home div:#header {background:url(home image path) no-repeat:}

body.custom.page div:#header {background:url(page image path) no-repeat:}

Essentially, this code says “If home then  show home header image; else if page then show page header image; else show standard header image”

Study the body tag and its classes. You can even zero in on specific pages or posts if you know their ID.

With the power invested in you by Clay in granting you use of Headway, you can do some pretty wild things with these page identifying classes combined with leafs. Being able to pull in content from any other page is one of Headway’s super powers.

On the  UMFC development site I’ve used this technique to show a background image on the container, and a transparent png on the content.

(Bear in mind this is where I’m testing Headway to see if it works on that site, so many pages are not configured. Go to the About page or Family Day Care, to see the default layout.)

Why would you do this? Well, you probably wouldn’t need to because in Headway it is so easy you’d just set up the home page different anyway. But I did it anyway probably because I decided in this case, with such small variation,  it was easier to manage.

You can argue otherwise, but really, whether it’s the best way or not, the point of this little tutorial is about making you think more deeply and creatively about how you can manipulate page layouts in Headway to achieve more complex designs.

Questions?

Related posts:

  1. Tutorial: Conditional Leafs in WordPress Headway (part 2)
  2. Screencast tutorial: Styling Multiple Leafs with Custom CSS Classes in WordPress Headway
  3. Tutorial: Coding a complex design using the WordPress Headway framework
  4. Headway tips: Using Custom Classes in Leafs
  5. Tutorial: Using Multiple Content Blocks plugin in Headway for WordPress
  • http://341design.com.au/tutorial-conditional-leafs-in-wordpress-headway-part-2/ Tutorial: Conditional Leafs in WordPress Headway (part 2) | three4one design

    [...] I woke up this morning and realised I’d not fully explained myself in yesterday’s tutorial about conditional leafs. [...]

  • http://341design.com.au/screencast-tutorial-styling-multiple-leafs-with-custom-css-classes-in-wordpress-headway/ Screencast tutorial: Styling Multiple Leafs with Custom CSS Classes in WordPress Headway | three4one design

    [...] Styling with Custom Classes – part 1 Styling with Custom Classes – part 2 [...]

  • Diane

    Is it possible to use one default header image for all pages except the posts and the blog index page? If so, how do I identify the posts and the blog index page?

  • Chris

    Diane

    Posts can be identified with .single, and the blog index page with .blog

  • Diane

    I still haven’t gotten this to work. Do you define your header image within the visual editor or leave it as a text heading?

  • Diane

    For anyone who might also have trouble implementing this, I was able to accomplish the same thing with this method:

    I used css:

    body.custom.blog div#header div#top { display: none;}
    body.custom.single div#header div#top {display:none;}

    and easy hook before header link I used:

  • http://www.innoexcel.com Website Designs Company UK

    Here we use some more custom.css to set this for pages that have a body class of “page”. Note that the home page of your blog, if you set it to an actual page, it will also have the class of “page” as well as “home”;

  • http://www.mactonweb.com web development bangalore

    Here we use some more custom.css to set this for pages that have a body class of “page”. Note that the home page of your blog.

  • http://www.marathonm2m.com/m-to-m-autmobiles-sector/m2m-communications.aspx m2m communications

    Great information with disqus…..

  • http://www.register-domainname.in Register domain names

    What a wonderful tutorial? Really you have done a good job. I agree with you. Everyone has a different opinion about blog even me too. You are also described differently about blog.

  • Web design London

    Great tutorial.Thanks for this wonderful info..

  • http://www.adsyou.com/ ??? ????? ?? ??????

    I agree with you. Everyone has a different opinion about blog even me too.

  • http://www.webhostings.in/ hosting server

    Thank you for sharing, this information is useful to me. good quality

  • http://www.webhostings.in/ hosting server

    I get it clear information about your topic.Above all the points are explained very clearly.

  • http://www.best-hostings.in/ Best web Hosting

    You designed several fantastic information there. I did a look for on the concern and found mainly people will go along with with your website.

  • http://blogfreakz.com/ Blog Freakz

    There’s a lot of good points around here thanks a lot for sharing it

  • http://www.webhostings.in/ Hosting company

    I got numerous positive points there. I made a search on the issue and found nearly all peoples will agree with your blog…Loving the information on this site.

blog comments powered by Disqus
© Copyright 2010, Chris Howard, three4one design
Site built using the Headway framework
Better Tag Cloud