Reputation: 33
I already found a question similar but it didn't click.
Here is my code, I want to have two backgrounds. I know how to add two backgrounds but one background image needs to be in a specific place accomplished by using divs. My code may have the most simple flaw. Please be aware I am a newbie and trying to get into web development again from what little knowledge I already knew.
<head>
<style type="text/css">
body {
<div id="currentpage">
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
</div>
}
#currentpage{
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
}
</style>
<?php include_once("general.php"); ?>
</head>
I may want to include that I have a general.php template that loads into every page, could that also affect the background from working?
Upvotes: 0
Views: 106
Reputation: 9542
**change your css and html**
<head>
<style type="text/css">
#currentpage{
position: absolute;
width:xx;
height:xx;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="currentpage"></div>
</body>
Upvotes: 1
Reputation: 1453
Change your code like this. Because you cannot apply html tag inside css like you where mention in your question.
<head>
<style type="text/css">
#currentpage{
position: absolute;
width:auto; /* specify width */
height:auto; /* specify height */
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="currentpage"></div>
</body>
And specify the width
and height
for div
displaying the image. otherwise you will have a white background.
Upvotes: 1
Reputation: 6877
Yes.you can not use div tags inside your css page or within css script.
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
use above code only your css page or within script tags but div tag not allow in css
Upvotes: 0
Reputation: 32172
Your html and css are incorrect. See the corrections below
<style type="text/css">
#currentpage{
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
and html do this
<div id="currentpage"></div>
Upvotes: 1