/    Sign up×
Community /Pin to ProfileBookmark

PSD to CSS – How to repeat a background?

So.

I have decided to convert my psd static pages into css… as I have learned that css is much easier to work with. This is quite a task since I am new to css, however, I would like to know:

How can I specify a main content area where the picture is a repeating background in which I can type on? It was easy from a table perspective because I simply inserted the background image and constrained the table width only. Does anyone have any suggestions?

Here is the code so far:
————————————————————————–

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>CSS Slicing Guide </title>
<style type=”text/css”>

#header {
height: 117px;
padding-bottom: 0px;
background:url(headers_01.gif);
}

#header2 {
position: relative;
top: 0px;
left: 0px;
}

#header3 {
position: relative;
top: 0px;
left: 0px;
}

#main {
width: 766px;
margin: 0 auto 0 auto;
float: left;
background-image:url(headers_04.gif/bg-repeat.png);
}

body {
margin: 0;
padding: 0;
text-align: center;
background-color: #333333;
}

#container {
width: 766px;
margin: 0 auto 0 auto;
text-align: left;
}

.clear {
clear: both;
}

</style>
</head>

<body>
<div id=”container”>
<div id=”header”> </div>
<div id=”header2″> <img id=”header2″ img src=”headers_02.gif” width=”766″ height=”287″/></div>
<div id=”header3″> <img id=”header3″ img src=”headers_03.gif” width=”766″ height=”95″/></div>

<div id=”content”>
<div id=”main”> </div>
<div class=”clear”></div>
</div>

</div>
</body>

</html>
————————————————————————–

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@ray326Nov 02.2007 — I think we need a link. The graphics are probably integral to the design.
Copy linkTweet thisAlerts:
@CentauriNov 02.2007 — Not sure what you mean here. Assuming #main is the content div with the background, just put the content inbetween the tags : [CODE]<div id="content">
<div id="main">
<p>Content stuff here</p>
<p>More content here</p>
</div>
<div class="clear"></div>
</div>
[/CODE]


Also note that as the #container div is already set to 766px wide, auto side margins on #content won't do anything.
Copy linkTweet thisAlerts:
@ne_plus_ultraauthorNov 02.2007 — Not sure what you mean here. Assuming #main is the content div with the background, just put the content inbetween the tags : [CODE]<div id="content">
<div id="main">
<p>Content stuff here</p>
<p>More content here</p>
</div>
<div class="clear"></div>
</div>
[/CODE]


Also note that as the #container div is already set to 766px wide, auto side margins on #content won't do anything.[/QUOTE]


Got it. Also I have a specific background design that I want to repeat within the content how can I repeat this background designed in photoshop so that I can type over it and it will expand in length while it holds a constant width value? Want to ensure I am wording that correctly. Thanks.
Copy linkTweet thisAlerts:
@CentauriNov 02.2007 — If you set a background image with no other parameters, it will be tiled in all directions by default. As you add more content, a div will naturally expand vertically as required (when no specific height is set), and if it has a set width, or is constrained by a wrapper, then the width will not change.

The action you want is the default without having to do anything else.
Copy linkTweet thisAlerts:
@ricklNov 03.2007 — 

#main {

width: 766px;

margin: 0 auto 0 auto;

float: left;

background-image:url(headers_04.gif/bg-repeat.png);

}
[/QUOTE]


Did you accidentally put two images in the background-image? Or is that acceptable syntax...
×

Success!

Help @ne_plus_ultra 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...