...

View Full Version : Tricky Background Stretch



baaaan
12-19-2007, 08:42 PM
I have a page with a tiled background and then a container DIV with a semi-transparent PNG for a background that is bigger at the top and at the bottom, but thinner in the middle. I want to make it so that the middle of this background will stretch if the content within the container div gets too long. I have no idea how to achieve this. I have uploaded an attachment with an example that I hope is somewhat clear.

If anyone could point me in the right direction or show me an example that does this, I would very much appreciate it!

Thanks,

Brandon

Excavator
12-19-2007, 09:05 PM
Hello baasan,
Probably a pretty easy fix... but we need to see your code.

baaaan
12-19-2007, 09:31 PM
I didn't have any code as I'm not sure what to try in order to solve the problem. I created this as a working example:

http://ohmedia.ca/bgstretch/

Excavator
12-20-2007, 12:57 AM
Hello again baaan,
Kind of hard to visualize what you're trying to do. Did you really want the top and bottom sections jogged over like they are in the link or are you trying to make it look like the picture in your first post.

Once you decide on what kind of image your going to use, you can just repeat it on the y-axis all the way down whatever div you want. Here's an example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<meta name="" content="authored by http://nopeople.com/Design" />
<style type="text/css">
html, body {
background: url(http://ohmedia.ca/bgstretch/bg.gif);
}
* {
margin: 0;
padding: 0;
border: none;
}
#container {
width: 563px;
/*height: 376px; remove height so container can expand with content*/
margin: 25px auto; /*pushes container down 25px and centers it*/
background: url(http://ohmedia.ca/bgstretch/containerbg.png) repeat-y;
}

#innercontainer {
width: 300px;
margin: 0 auto; /*centers innercontainer*/
line-height: 26px;
}
</style>
</head>
<body>
<div id="container">
<div id="innercontainer">
<p>
I want the narrower part of the background of #container to stretch if this text takes up
enough space.
</p>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo
duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo
duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
<!--end innercontainer--></div>
<!--end container--></div>
</body>
</html>


If you want rounded corners there are a few different methods. Here's a couple different examples:
one (http://nopeople.com/CSS/rounded%20corners/)
two (http://nopeople.com/CSS/slider/)

To see how those are done just click View Source in your browser.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum