943,682 Members | Top Members by Rank

Ad:
Jul 9th, 2009
0

Wht kind of logic has been used here ?

Expand Post »
Hi,
Please visit http://www.iplt20.com/ipl-delhidaredevils.shtml


All the elements on the site are kind of transparent and we can always see the background even if we scroll down.

I am surprised and was wondering how did the developer do this ?

Would appreciate if the community can give their feedback.


Cheers,
Vishal
Similar Threads
Reputation Points: 47
Solved Threads: 0
Junior Poster
vishalkhialani is offline Offline
127 posts
since Mar 2007
Jul 10th, 2009
0

Re: Wht kind of logic has been used here ?

Hi Vishal. =)

There isn't much of a trick there. The main content of the page is a table with no background. The background image was used on the body (CSS for that below). The 'translucent' effect of the image was made using the image editor itself. Probably a logo, set at 70% opacity on the same background color as the page to be used.

Here's the background image they used:
http://www.iplt20.com/assets/images/bg-dd.jpg

Here is an approximation of the html and css code for it:
<html><head><title>MEEP</title>
<style type="text/css">
<!--
body {
background-color: #18335E;
background-image: url('http://www.iplt20.com/assets/images/bg-dd.jpg);
background-position: right;
background-repeat: no-repeat;
background-attachment: fixed;
}
-->
</style></head>
<body>
<table>
<tr><td>Some content</td></tr>
<tr><td>Another row</td></tr>
</table>
</body>
</html>

As you can see, all the 'trick' is done by manipulating the body's properties in CSS. =)
The first two background properties aren't important, they just refer to the background color and location of the background image to be used. But it works this way: if your background image does not cover the whole part of the page, the background color fills up the rest of the page's background.

The next properties are the trick part.
The CSS is pretty self-explanatory in that setting background-position: right means that you're positioning the background-image on the right part of the page. You can change that using a combination of top/bottom and left/right. (For example, you can have background-position: top left; or background-position: bottom right; but certainly not top bottom! (You can also use a center value but I can't instruct you properly in that. Sorry.)
The line after that says no-repeat. Which is also obvious. You don't want the background image to 'tile' the page. Other values for background-repeat are repeat-x and repeat-y. Repeat-x means that your background image will tile along the x-axis (horizontally), and repeat-y will tile vertically. Both of which have lots of applications. =)
The last CSS property, setting a background-attachment to a value of fixed means that you don't want the background image to 'scroll' with the page. You want it fixed in the position you specified (using background-position). Or if you didn't specify a position, it will default to top left.

I hope you read through all that hulla-balloo (and I said that the answer was simple)! So I'll leave you with the shorthand code for background properties equivalent to the CSS code above:
HTML and CSS Syntax (Toggle Plain Text)
  1. body {
  2. background: #18335E url('http://www.iplt20.com/assets/images/bg-dd.jpg') no-repeat fixed right;
Last edited by kanaku; Jul 10th, 2009 at 4:07 pm. Reason: tried to make me more understandable... failed horribly too, it would seem. =(
Reputation Points: 70
Solved Threads: 15
Posting Whiz
kanaku is offline Offline
378 posts
since Jan 2007
Jul 10th, 2009
0

Re: Wht kind of logic has been used here ?

Hi,
Thank you for the detailed explanation
Reputation Points: 47
Solved Threads: 0
Junior Poster
vishalkhialani is offline Offline
127 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Div Scroll Bug in IE - How to overcome?
Next Thread in HTML and CSS Forum Timeline: Drop down Menu





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC