Jump to content

How to shorten my css codes?


Recommended Posts

I have the following css codes:


/* special_size.tpl */
#special_size  h2 { background: transparent url('../img/block_header_large2.gif')  no-repeat top left; }
#special_size #right_column { display: none; }
#special_size #center_column {
   width: 767px;
   margin: 0 0 30px 0;
   text-align: left;
    float:left;
}


/* material.tpl */
#material h2 { background: transparent url('../img/block_header_large2.gif')  no-repeat top left; }
#material #right_column { display: none; }
#material #center_column {
    width: 767px;
   margin: 0 0 30px 0;
   text-align: left;
    float:left;
}




How can I combine these two since they are using the same codes?
Link to comment
Share on other sites

Use comma for your selectors:

#special_size h2, #material h2 {
   background: transparent url('../img/block_header_large2.gif')  no-repeat top left;
}
#special_size #right_column, #material #right_column {
   display: none;
}
#special_size #center_column, #material #center_column {
   width: 767px;
   margin: 0 0 30px 0;
   text-align: left;
   float:left;
}


You can also shorten margin attributes like this:

margin: 0 0 30px;


Margins and paddings rule:
T stands for Top, R - right, B - bottom, L - left
1 set (margin: 5px;): T R B L
2 set (margin: 10px, 5px;): (T B) (L R) (Top and Bottom: 10px margin, left and right: 5px margin)
3 set (margin: 10px, 5px, 8px;): T (L R) B (Top: 10px, Left and Right: 5px, Bottom: 8px;)
4 set: T R B L

Link to comment
Share on other sites

Use comma for your selectors:
#special_size h2, #material h2 {
   background: transparent url('../img/block_header_large2.gif')  no-repeat top left;
}
#special_size #right_column, #material #right_column {
   display: none;
}
#special_size #center_column, #material #center_column {
   width: 767px;
   margin: 0 0 30px 0;
   text-align: left;
   float:left;
}


You can also shorten margin attributes like this:

margin: 0 0 30px;


Margins and paddings rule:
T stands for Top, R - right, B - bottom, L - left
1 set (margin: 5px;): T R B L
2 set (margin: 10px, 5px;): (T B) (L R) (Top and Bottom: 10px margin, left and right: 5px margin)
3 set (margin: 10px, 5px, 8px;): T (L R) B (Top: 10px, Left and Right: 5px, Bottom: 8px;)
4 set: T R B L



Wow, thank you. You just taught me a lot. Thank you again.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...