01 Mar 2010 @ 2:07 PM

Evening All

How many times it happend that you got a design to cut/slice from a designer only (or you yourself are a designer) only to find out that the background of the PSD is unequal on both sides, for example you have a curbed line in the middle, and on the left the repeating line is placed on top while on the right side it goes in the middle. Something like this:

Uneven repeating backgrounds ilustrated

Notice the marked areas, well i found a pretty awesome and easy to implement solution. You slice the marked images and you do the following. When you have your main page container, as it’s siblings you create 2 new divs, bgHelperLeft and bgHelperRight and you style them something like this

 .bgHelperLeft  { position: absolute; z-index: -1; width: 50%; top: 0px (or where your background is); left: 0px; background-image: .. background-repeat: repeat-x; background-position: top left;}
 .bgHelperRight { position: absolute; z-index: -1; width: 50%; top: 0px (or where your background is); right: 0px;  background-image: .. background-repeat: repeat-x; background-position: top left; }

Since you used z-index: -1; then it means that it wont overlap any of your center images, absolute positioning means that it will stay there, and those widths means that they will meet BEHIND your center area so the user wont see the binning point, all creating a cursive flow from one side of the screen to the other side of the screen.

It works on all major browsers so this is a good trick to know and have in the book.

Questions in comments

Posted By: Dinulescu Alexandru Adrian

Last Edit: 01 Mar 2010 @ 02:11 PM

EmailPermalink

Responses to this post » (None)

Post a Comment

XHTML: You can use these tags: <strong> <em> <a href="" title="">

Spam Protection by WP-SpamFree