+ Reply to Thread
Results 1 to 6 of 6

Thread: CSS Tips and Trix

  1. #1
    intertec's Avatar
    intertec is offline x10 Elder intertec is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Brisbane, Australia
    Posts
    946

    CSS Tips and Trix

    CSS shortcuts
    In css there is many shortcuts that will spear you and others some time. Using shortcut will also make your code look better and it will save you some time. For instance:#bad_example
    {
    background-image: url(image);
    background-color: #00000;
    background-repeat: repeat-x;
    background-position: top left;
    }

    #good_example { background: #000 url(image) repeat-x top left; }So if we look at the both examples we can see that the #good_example looks much better and needs only 1 line. The background properties works like this:
    background: [color] [image] [repeat] [position] [attachment];

    There is many other shortcuts so i won’t show everyone, but here’s how margin/padding works:
    #bad_example
    {
    margin-top: 1px;
    margin-right: 2x;
    margin-bottom: 3px;
    margin-left: 4px;
    }

    #good_exmple { margin: 1px 2px 3px 4px; }

    If we look at this one, we can see that the margin/padding works like this:
    margin: [top] [right] [bottom] [left];

    If all off them is the same size you will only need to write margin: [pixels]. But there’s some other tips you could use with margin:
    #margin { margin: 2px 5px; } /* [Top/Bottom] [Right/Left] */
    #margin { margin: 2px 5px 1px; } /* [Top] [Right/Left] [Bottom] */

    Writing good structured code
    It’s important to write nice looking and structured codes, it will be simpler to see and edit and it’s nice to your eyes. Good looking codes is different from people to people, but a tip is to block your styles, wich means that you’re blocking the child of an element, like this:
    #menu li { /* some neat code here */ }
    #menu li a { /* this is the child of #menu li }


    By doing this you can see your childs better and it will make it easier to edit your code.
    Hacks for IE
    Some of you out there is still working like hell to make your site look the same in Internet Explorer as in the “modern” browsers. While doing this you may use ugly hacks like:
    /* IE<7 */
    #div { /* some changes for IE */ }

    But in my opinion that’s just wrong, it takes unnecessary space in your documents, what you should do is to use conditional statements, and they work like this:
    <head>
    <link type="text/css" rel="stylesheet" href="normal.css" />
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="internet-explorer.css" />
    < ![endif]--></head>




  2. #2
    djviraj is offline x10Hosting Member djviraj is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    3

    Re: CSS Tips and Trix

    Quote Originally Posted by intertec View Post
    CSS shortcuts
    In css there is many shortcuts that will spear you and others some time. Using shortcut will also make your code look better and it will save you some time. For instance:#bad_example
    {
    background-image: url(image);
    background-color: #00000;
    background-repeat: repeat-x;
    background-position: top left;
    }

    #good_example { background: #000 url(image) repeat-x top left; }So if we look at the both examples we can see that the #good_example looks much better and needs only 1 line. The background properties works like this:
    background: [color] [image] [repeat] [position] [attachment];

    There is many other shortcuts so i won’t show everyone, but here’s how margin/padding works:
    #bad_example
    {
    margin-top: 1px;
    margin-right: 2x;
    margin-bottom: 3px;
    margin-left: 4px;
    }

    #good_exmple { margin: 1px 2px 3px 4px; }

    If we look at this one, we can see that the margin/padding works like this:
    margin: [top] [right] [bottom] [left];

    If all off them is the same size you will only need to write margin: [pixels]. But there’s some other tips you could use with margin:
    #margin { margin: 2px 5px; } /* [Top/Bottom] [Right/Left] */
    #margin { margin: 2px 5px 1px; } /* [Top] [Right/Left] [Bottom] */

    Writing good structured code
    It’s important to write nice looking and structured codes, it will be simpler to see and edit and it’s nice to your eyes. Good looking codes is different from people to people, but a tip is to block your styles, wich means that you’re blocking the child of an element, like this:
    #menu li { /* some neat code here */ }
    #menu li a { /* this is the child of #menu li }


    By doing this you can see your childs better and it will make it easier to edit your code.
    Hacks for IE
    Some of you out there is still working like hell to make your site look the same in Internet Explorer as in the “modern” browsers. While doing this you may use ugly hacks like:
    /* IE&lt;7 */
    #div { /* some changes for IE */ }

    But in my opinion that’s just wrong, it takes unnecessary space in your documents, what you should do is to use conditional statements, and they work like this:
    <head>
    <link type="text/css" rel="stylesheet" href="normal.css" />
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="internet-explorer.css" />
    < ![endif]--></head>

    thankzz

  3. #3
    intertec's Avatar
    intertec is offline x10 Elder intertec is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Brisbane, Australia
    Posts
    946

    Re: CSS Tips and Trix

    no worries!

  4. #4
    sunils's Avatar
    sunils is offline x10 Spammer sunils is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Chennai ,India
    Posts
    2,264

    Re: CSS Tips and Trix

    good and an essential post
    [LEFT][B]Sunil Sankar
    -------------------------------------------------------------------------

  5. #5
    4h26x is offline x10Hosting Member 4h26x is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    5

    Re: CSS Tips and Trix

    you can find more css tutorials here http://www.w3schools.com/css/default.asp

  6. #6
    mac173's Avatar
    mac173 is offline x10Hosting Member mac173 is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    94

    Re: CSS Tips and Trix

    Outstanding tutorials here, they are intended to support college level classes.

    http://it.maconstate.edu/tutorials/
    Just call me Grandpa Geek!

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers