OK, here's a little CSS trick

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harvey
    Confirmed User
    • Jul 2001
    • 9266

    #1

    OK, here's a little CSS trick

    so I really got tired of fixing some CSS sheets with HORRORS (they're not even errors), therefore here's a tip for you guys to save bandwidth, make spacing coherent and clear floats all at once while saving time.

    First, for those that still don't know (the vast majority for what I see), you should do something at the top of every stylesheet: reset everything. I won't go further on that since there are gazillions of tutorials on it.

    So while you're resetting everything, add this:

    Code:
    hr{clear:both; visibility:hidden; margin:10px 0;}
    
    /* modify the margin to whatever you want */

    Now, every time you need some spacing or clear floats, instead of redefining or adding elements, simply add the <hr/> tag and that's it

    of course, in the event that you need a real <hr> simply define it like <hr class="whatever" />, but chances are 99 times out of 100 you won't need the hr tag. Hell, if I remember right the last time I used the hr tag was in 1998!

    Anyway, hope you like it
    This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth
  • JD
    Too lazy to set a custom title
    • Sep 2003
    • 22651

    #2
    nifty trick and yeah i agree on the 1998 thing about HR's

    I do the same thing with a clear class like

    Code:
    .clear {clear:both;}
    and use it on page with
    Code:
    <div class="clear" style="height:xxpx;"></div>
    different strokes for different folks :D

    Comment

    • CS-Jay
      Confirmed User
      • Oct 2003
      • 1794

      #3
      I use the JD method, but I like the hr idea too.
      I do stuff - aIm CS_Jay_D

      Comment

      • AIbenjamink
        Confirmed User
        • Jan 2009
        • 420

        #4
        Originally posted by JD

        Code:
        .clear {clear:both;}
        Code:
        <div class="clear" style="height:xxpx;"></div>
        Benjamin : [email protected] : 405-243-447 : www.AdultInterface.com

        Comment

        • HighEnergy
          So Fucking Banned
          • Apr 2007
          • 806

          #5
          Originally posted by JD
          nifty trick and yeah i agree on the 1998 thing about HR's

          I do the same thing with a clear class like

          Code:
          .clear {clear:both;}
          and use it on page with
          Code:
          <div class="clear" style="height:xxpx;"></div>
          different strokes for different folks :D
          All's well that ends well .... but ....
          1) for predictable cross-browser results call every variable at the beginning of the style sheet.

          ie:
          font-family
          font-size
          font-style
          line-height
          margin
          padding
          p margin
          p padding
          div margin
          div padding
          i margin
          i padding
          em margin
          em padding
          etc
          etc
          etc
          Just obey cascading for the best results.

          I keep all base (global) styling in a 'base' file to be read 1st.
          Then unique page/site styling in a unique CSS file to be read 2nd.



          ...

          Comment

          • RyuLion
            • Mar 2003
            • 32369

            #6
            guess what this does?

            #index_table IMG:hover {
            BORDER-RIGHT: #f09 2px ridge;
            border-top: #f09 2px ridge;
            border-bottom: #f09 2px ridge;
            border-left: #f09 2px ridge;
            FLOAT: left; MARGIN: 0px 5px 0px 0px;

            Adult Biz Consultant A tech head since 1995
            Affiliate Support: Chaturbate | CCBill Live

            Comment

            • HighEnergy
              So Fucking Banned
              • Apr 2007
              • 806

              #7
              Originally posted by RyuLion
              guess what this does?

              #index_table IMG:hover {
              BORDER-RIGHT: #f09 2px ridge;
              border-top: #f09 2px ridge;
              border-bottom: #f09 2px ridge;
              border-left: #f09 2px ridge;
              FLOAT: left; MARGIN: 0px 5px 0px 0px;
              It doesn't do jack shit unless you have an element named index_table

              Comment

              • StuartD
                Sofa King Band
                • Jul 2002
                • 29903

                #8
                http://www.gfy.com/showthread.php?p=12733093
                This is me on facebook
                This is me on twitter

                Comment

                • Deej
                  I make pixels work
                  • Jun 2005
                  • 24386

                  #9
                  Originally posted by StuartD
                  Yea what the fuck you posers!

                  StuartD invented CSS

                  Deej's Designs n' What Not
                  Hit me up for Design, CSS & Photo Retouching


                  Icq#30096880

                  Comment

                  • Basic_man
                    Programming King Pin
                    • Oct 2003
                    • 27360

                    #10
                    I like the simplicity of your HR trick! I should start using it
                    UUGallery Builder - automated photo/video gallery plugin for Wordpress!
                    Stop looking! Checkout Naked Hosting, online since 1999 !

                    Comment

                    • dallasnovelty
                      Confirmed User
                      • Aug 2009
                      • 1056

                      #11
                      Thanks for sharing your tips. I am just learning how to do all the css stuff.
                      | Dallas Novelty Blog | Facebook

                      Comment

                      • harvey
                        Confirmed User
                        • Jul 2001
                        • 9266

                        #12
                        Originally posted by JD
                        nifty trick and yeah i agree on the 1998 thing about HR's

                        I do the same thing with a clear class like

                        Code:
                        .clear {clear:both;}
                        and use it on page with
                        Code:
                        <div class="clear" style="height:xxpx;"></div>
                        different strokes for different folks :D
                        yeah, but my solution is for lazy mofos like me who just want to type 5 chars


                        Originally posted by RyuLion
                        guess what this does?

                        #index_table IMG:hover {
                        BORDER-RIGHT: #f09 2px ridge;
                        border-top: #f09 2px ridge;
                        border-bottom: #f09 2px ridge;
                        border-left: #f09 2px ridge;
                        FLOAT: left; MARGIN: 0px 5px 0px 0px;
                        any time a girl sees that code she feels an irresistible urge to get her ass bitten


                        Originally posted by StuartD
                        nice thread indeed

                        Originally posted by Deej
                        Yea what the fuck you posers!

                        StuartD invented CSS
                        yeah, but my thing is CZZ, which is only for l33t people
                        This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth

                        Comment

                        • Deej
                          I make pixels work
                          • Jun 2005
                          • 24386

                          #13
                          Originally posted by harvey



                          yeah, but my thing is CZZ, which is only for l33t people
                          O i sees - Well you mis titled then

                          Keep up the good shit

                          Deej's Designs n' What Not
                          Hit me up for Design, CSS & Photo Retouching


                          Icq#30096880

                          Comment

                          • Killswitch - BANNED FOR LIFE

                            #14
                            Code:
                            .clearFix:after {
                            	visibility: hidden;
                            	display: block;
                            	font-size: 0;
                            	content: " ";
                            	clear: both;
                            	height: 0;
                            }
                            .clearFix {
                            	display: inline-block;
                            }
                            /* start commented backslash hack \*/
                            * html .clearFix {
                            	height: 1%;
                            }
                            .clearFix {
                            	display: block;
                            }
                            /* close commented backslash hack */
                            *, html {
                            	margin: 0;
                            }

                            Comment

                            • Deej
                              I make pixels work
                              • Jun 2005
                              • 24386

                              #15
                              Code:
                              * {margin:0;padding:0;}
                              tops all...

                              Deej's Designs n' What Not
                              Hit me up for Design, CSS & Photo Retouching


                              Icq#30096880

                              Comment

                              • calmlikeabomb
                                Confirmed User
                                • May 2004
                                • 1323

                                #16
                                Here is another tip - minify your style sheets to save bandwidth:

                                http://code.google.com/p/minify/
                                subarus.

                                Comment

                                • JD
                                  Too lazy to set a custom title
                                  • Sep 2003
                                  • 22651

                                  #17
                                  Originally posted by Deej
                                  Code:
                                  * {margin:0;padding:0;}
                                  tops all...
                                  lol

                                  Comment

                                  Working...