/    Sign up×
Community /Pin to ProfileBookmark

background image to expand with text

Hi,

I am having trouble getting a background image to be displayed in my main div content container. This is to create a background color. I have the main content container and inside of that container I have 3 other containers. These are the leftContent div, middleContent div and rightContent div. I want to have the background color to be visible throughout the 3 containers so I have placed it in the mainContent container.

[COLOR=”Blue”]CSS Code:

#mainContent {
background-image: url(bg.jpg);
background-repeat: repeat-y;
background-color: #35281E;
width: 915px;
height: 500px; *** only works with height for me? ***
}

#leftContent {
width:167px;
background-color:#E7E7E7;
float:left;
padding: 10px;
}

#middleContent {
float:left;
padding: 15px;
width: 417px;
}

rightContent {
float:right;
padding: 15px;
width:250px;
border-left-width: 1px;
border-left-style: solid;
border-left-color: #E7E7E7;
}[/COLOR]

[COLOR=”Teal”]html code:

<div id=”mainContent”>

<div id=”leftContent”> </div>
<div id=”middleContent”> </div>
<div id=”rightContent”> <div>

</div>
[/COLOR]
Can someone please advise if I have the css correct for the mainContent div as the only way I can get the image to display is by placing a height value into the mainContent div. This makes the page a certain height and when I add text into the middleContent container the text moves down but the background image is fixed to a certain height. However, I want this image to move downwards with additional text instead of been fixed to a certain height. Any help is appreciated.

regards,
elv8.

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@WebitseoMar 02.2009 — If I understand correctly what you're asking, this might help. Try adding this to the #mainContent element : background-attachment: scroll;
Copy linkTweet thisAlerts:
@WebitseoMar 02.2009 — Try this:

#mainContent {

height:500px;

width: 915px;

}

#mainContent p{

background-image: url(bg.jpg);

background-repeat: repeat-y;

background-color: #35281E;

width: 915px;

}

Obviously you'll need to put your text in <p></p> brackets.

This sets the height of the content, and keeps the color with the size of the entire text area.
×

Success!

Help @elv8 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...