krates
25-08-2007, 02:56 PM
Set an image as the background
You already know that you have to put Css after the head tag so if you want to put a background image the syntax of it will be:
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’http://www.hostforpost.com/glossytheme/logo.png (http://www.hostforpost.com/glossytheme/logo.png%29)')
}
</style>
</head>
<body>
</body>
</html>
The red bolded part is the Css syntax for putting the background image.
url(’http://www.hostforpost.com/glossytheme/logo.png)
in the above syntax replace the black line with your image url
Note:This syntax will repeat the same image again and again
How to repeat a background image only vertically
The syntax of it is given below:
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’http://www.hostforpost.com/glossytheme/logo.png ‘);
background-repeat: repeat-y
}
</style>
</head>
<body>
</body>
</html>
The above syntax is same accept this line background-repeat: repeat-y this line will make the image repeat only vertically
How to repeat a background image only horizontally
The syntax of it is given below:
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’lol.jpg’);
background-repeat: repeat-x
}
</style>
</head>
<body>
</body>
</html>
The above syntax is same accept this line background-repeat: repeat-x this line will make the image repeat only horizontally
How to display a background image only one time
The syntax of it will be:
<html>
<head>
<style type=”text/css”>
body
{
background-image: url(’bgdesert.jpg’);
background-repeat: no-repeat
}
</style>
</head>
<body>
</body>
</html>
The above syntax is same accept this line background-repeat: no-repeat
This line will make the image not to repeat
How to position a background image using %
See the syntax below:
<html>
<head>
<style type=”text/css”>
body
{
background-image: url(‘lol.jpg’);
background-repeat: no-repeat;
background-position: 30% 20%;
}
</style>
</head>
<body>
</body>
</html>
Please replace (‘lol.jpg’); the bold black part with you image url
A fixed background image (this image will not scroll with the rest of the page)
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’lol.jpg’);
background-repeat:
no-repeat;
background-attachment:
fixed
}
</style>
</head>
<body>
<p>Please scroll down to the end of the page and you will notice that the image will not scroll along with the rest of the text</p>
</body>
</html>
Now The image will not scroll along with the text the new lines added were
background-repeat:
no-repeat;
background-attachment:
fixed
If you like it then leave a comment here (http://www.easytutorial.info/?p=21)
You already know that you have to put Css after the head tag so if you want to put a background image the syntax of it will be:
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’http://www.hostforpost.com/glossytheme/logo.png (http://www.hostforpost.com/glossytheme/logo.png%29)')
}
</style>
</head>
<body>
</body>
</html>
The red bolded part is the Css syntax for putting the background image.
url(’http://www.hostforpost.com/glossytheme/logo.png)
in the above syntax replace the black line with your image url
Note:This syntax will repeat the same image again and again
How to repeat a background image only vertically
The syntax of it is given below:
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’http://www.hostforpost.com/glossytheme/logo.png ‘);
background-repeat: repeat-y
}
</style>
</head>
<body>
</body>
</html>
The above syntax is same accept this line background-repeat: repeat-y this line will make the image repeat only vertically
How to repeat a background image only horizontally
The syntax of it is given below:
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’lol.jpg’);
background-repeat: repeat-x
}
</style>
</head>
<body>
</body>
</html>
The above syntax is same accept this line background-repeat: repeat-x this line will make the image repeat only horizontally
How to display a background image only one time
The syntax of it will be:
<html>
<head>
<style type=”text/css”>
body
{
background-image: url(’bgdesert.jpg’);
background-repeat: no-repeat
}
</style>
</head>
<body>
</body>
</html>
The above syntax is same accept this line background-repeat: no-repeat
This line will make the image not to repeat
How to position a background image using %
See the syntax below:
<html>
<head>
<style type=”text/css”>
body
{
background-image: url(‘lol.jpg’);
background-repeat: no-repeat;
background-position: 30% 20%;
}
</style>
</head>
<body>
</body>
</html>
Please replace (‘lol.jpg’); the bold black part with you image url
A fixed background image (this image will not scroll with the rest of the page)
<html>
<head>
<style type=”text/css”>
body
{
background-image:
url(’lol.jpg’);
background-repeat:
no-repeat;
background-attachment:
fixed
}
</style>
</head>
<body>
<p>Please scroll down to the end of the page and you will notice that the image will not scroll along with the rest of the text</p>
</body>
</html>
Now The image will not scroll along with the text the new lines added were
background-repeat:
no-repeat;
background-attachment:
fixed
If you like it then leave a comment here (http://www.easytutorial.info/?p=21)