Created
April 14, 2013 23:31
-
-
Save kdipietro/5384702 to your computer and use it in GitHub Desktop.
A CodePen by kdipietro. CSS Backgrounds Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--YOU MAY ADJUST THE CODE FOR YOUR OWN TINKERING KNOWLEDGE, BUT DO NOT CLICK SAVE! --> | |
<body> | |
<h1>CSS Backgrounds</h1> | |
<p id="p1">This is an example of background image positioning with CSS.</p> | |
<p id="p1">What we have done here is linked to a background image from an image hosting site, and told the webpage how to position the image.</p> | |
<p id="p1">Notice that as we scroll down, the background image stays fixed in position, because of the "background-attachment" attribute.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p>.</p> | |
<p id="p1">End.</p> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* YOU MAY ADJUST THE CODE FOR YOUR OWN TINKERING KNOWLEDGE, BUT DO NOT CLICK SAVE */ | |
h1{ | |
font-family: Futura; | |
color: red; | |
text-decoration: underline; | |
} | |
#p1{ | |
font-family: Futura; | |
color: dark-grey; | |
} | |
body{ | |
background-image:url('http://i.imgur.com/UzlGbpr.jpg'); | |
background-repeat:no-repeat; | |
background-position:right bottom; | |
background-attachment: fixed; | |
background-size: 500px; | |
} | |
/* By default, the HTML document uses the "scroll" value for the "background-attachment" attribute. This means that the background image will scroll along the page. | |
The image that we've referenced is native sized at 720px x 888px. Notice that we can use the "background-size" attribute to resize the image. You can add two values to resize the image (x,y), but in this case we've only added the width (x) size that we want and the height (x) size will be scaled down uniformly. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment