Skip navigation
NicholasEZ
Currently Being Moderated

Advanced CSS Help!

Nov 2, 2011 11:59 AM

Tags: #css #styles #dw #dreamweaver_cs5.5

I'm using Dreamweaver CS5.5 as part of the CS5.5 master collection.

 

On my website I currently have a single style sheet (named style.css) and it contains 7 styles (.background, .networking, .header, .footer, .main, .mainround, .instruction).

 

Each page is constructed as follows:

 

.background is applied

 

.networking is applied to a table at the very top

 

.header is applied to a table below the .networking table

 

.main, .mainround, and/or .instruction is applied to table(s) within the body of the website

 

.footer is applied to the lowest table

 

The following is the same on EVERY single page of my site.

 

The .background style is applied to every page (consists of background-image, background-scroll: scroll; and background-repeat: no-repeat)

 

The .networking table will be including links/scripts to share my site on social networking websites.

 

The .header table includes my site logo as well 5 rollover images/links.

 

The .footer table inludes to rollover images/links.

 

What I want to do:

 

I want my "main" style to include all the information of the 4 aformentioned styles in one.  For instance, say I name the style (within my style.css file) .background.  When I apply .background to my site's body, at want that page to now have my background image and settings, the networking table with functioning links, the header table with my logo and rollovers and the footer tables with my rollovers.  Though is nothing is contained in tables and are contained in something else, that is fine, as long as it is eficient and I get the desired style / effect!

 

Currently everything is centered on the page with auto left and right margins, the appropriate top margin to keep everything in order and properly spaced, and no bottom margin.  I would need these settings/styles to remain, and I would need to be able to insert my site's content between the header and footer tables.  If I need to exclude the footer table, I understand, but I feel everything else I want to do should be quite possible.

 

Thank you for your help fellow forum users.  You have been an amazing help so far and I look forward to the day where I can actually answer someone else's questions!

 
Replies
  • Currently Being Moderated
    Nov 2, 2011 12:16 PM   in reply to NicholasEZ

    Too hard to follow.  Please upload the page and post a link to it.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 2, 2011 12:25 PM   in reply to NicholasEZ

    A table-based layout is not the way to go for any page design, but especially not this one!

     

    How about the CSS for this page?  <sigh>  uploading the page and posting a link is the only fast way to do this.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 2, 2011 12:32 PM   in reply to MurraySummers

    Tables bad DIVs good.

     

    I rewrote a tabled page (that was 587 lines long) with DIVs and it was 248 lines when I was done. Looked identical but 39kb vs 13kb? Hands down a faster page, cleaner code, and smaller for FTP.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 2, 2011 12:59 PM   in reply to NicholasEZ

    I can't upload it to the site as my site gets quite a bit of traffic

     

    Of course you can.  Save the file as "temp-whatever.php" and upload it.  When diagnosis is done, take it down.  Or save it in a folder called "temp" or my favorite folder name "monkeybutt", and upload it.  Doesn't matter how much traffic your site gets - nobody will see the page except those of us trying to help you.

     

    And what should I be using instead of tables?  APDivs?

     

    Definitely not.  You should be using good practices!  Read this to see what I mean - http://www.apptools.com/examples/pagelayout101.php

     

    OK - I'll see what I can find now that I have the HTML and CSS.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 2, 2011 1:08 PM   in reply to NicholasEZ

    I want my "main" style to include all the information of the 4 aformentioned styles in one.

     

    Can't happen, because within the styles that get applied to EVERYTHING, you have styles that should only be applied to certain page elements.  That's not to say that you can't improve and simplify your CSS -

     

    body {

              width:800px;

              background-color: #FFF;

              background-image: url(images/background.png);

              background-repeat: no-repeat;

              margin:0 auto;

              padding: 0;

    }

    .header {

              margin-top: 20px;

    }

    .footer {

              height: 18px;

              margin-top: 10px;

    }

    .instruction {

              font-family: "Myriad Pro", arial, helvetica, sans-serif;

              font-size: 24px;

              text-align: center;

              vertical-align: middle;

              padding: 5px;

              margin-top: 10px;

    }

    .main {

              margin-top: 10px;

              font-size: 16px;

    }

    .mainround {

              margin-top: 10px;

              border-radius: 20px;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 2, 2011 1:57 PM   in reply to NicholasEZ

    Take note of the changes I made to your CSS.  See if you can understand why I made them....

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 3, 2011 9:12 AM   in reply to NicholasEZ

    The width, margin and padding in the body makes it so any tables or divs that I add to my site will have auto margins on the left and right as well as a width of 800px.

     

    It restricts the body to 800px of usable width which will be centered within the browser's viewport.  And elements added to the body will be constrained by that width.  So you are close if not exact.

     

     

    I don't understand the white background color that you have applied.

     

    You should declare a background color for the page, even when it's white.

     

    I also don't understand the addition to the font on .instruction ( font-family: "Myriad Pro", arial, helvetica, sans-serif;).  Does this make it so if a browser doesn't support one font, it goes to the next available font?

     

    Bingo.  Not everyone is going to have Myriad Pro installed. And the browser default of Times/Times New Roman is what's used if Myriad Pro isn't found.  Ugly....

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 3, 2011 9:16 AM   in reply to NicholasEZ

    You're welcome.  Good luck!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points