/    Sign up×
Community /Pin to ProfileBookmark

Background-Image Problems

Hey all,

I am trying to create a css box using background images in the pic [URL=http://img212.imageshack.us/img212/2372/cssboxcorrectmf1.gif]CSS Box[/URL], but I am getting this [URL=http://img204.imageshack.us/img204/9277/cssboxyh5.gif]CSS Box[/URL] in IE and FireFox.

The box is 250px wide with the height to vary depending on the content inside. I have tried repeat, repeat-x, repeat-y, no-repeat, fixed, scroll, inherit, auto, etc for the background attributes without success. If I set a fixed height like 200px, it works; but I don’t want a fixed height due to the contents will shrink or expand the box. Is there a better way in doing this other than inserting the images in the divs themselves that I am unaware? And I have been googling for a solution for over a day now. :p

How can I get the side images to repeat?

Thank you. ?

Below is the HTML:

[CODE]<head>
<title>Box</title>
<link href=”box.css” rel=”stylesheet” type=”text/css” />
</head>
<body>
<div class=”divtl”></div>
<div class=”divt”></div>
<div class=”divtr”></div>
<div class=”clear”></div>
<div class=”divl”>&nbsp;</div>
<div class=”divm”>
test1<br />
test2<br />
test3<br />
test4<br />
</div>
<div class=”divr”>&nbsp;</div>
<div class=”clear”></div>
<div class=”divbl”></div>
<div class=”divb”></div>
<div class=”divbr”></div>
</body>
</html>[/CODE]

Below is the box.css file:

[CODE].divtl /* top left */
{
width: 22px;
height: 22px;
float: left;
background-image: url(box_top_left.gif);
}
.divt /* top */
{
height: 22px;
width: 206px;
float: left;
background-image: url(box_top.gif);
}
.divtr /* top right */
{
height: 22px;
width: 22px;
float: left;
background-image: url(box_top_right.gif);
}
.divl /* left */
{
width: 22px;
float: left;
background-image: url(box_left.gif);
}
.divm /* middle */
{
width: 206px;
float: left;
background-color: #FAFAFA;
}
.divr /* right */
{
width: 22px;
float: left;
background-image: url(box_right.gif);
}
.divbl /* bottom left */
{
width: 22px;
height: 22px;
float: left;
background-image: url(box_bottom_left.gif);
}
.divb /* bottom */
{
height: 22px;
width: 206px;
float: left;
background-image: url(box_bottom.gif);
}
.divbr /*bottom right */
{
height: 22px;
width: 22px;
float: left;
background-image: url(box_bottom_right.gif);
}
.clear /* clear floats */
{
clear: both;
}[/CODE]

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@timdentyOct 27.2006 — Ah - the old rounded corner one. There seems to be many people looking to do this.

Check my post in this thread...

http://www.webdeveloper.com/forum/showthread.php?t=125110&highlight=bullet

as it may help
Copy linkTweet thisAlerts:
@timdentyOct 27.2006 — Also, it's quite flexible what you apply your background images to - you could apply the top image to a <H1> and the lower image to the aprent element. Depends what you want to put inside there really.

T
Copy linkTweet thisAlerts:
@drallabauthorOct 27.2006 — Thanks Tim.

I saw the thread you linked me to and it did get me thinking. I was thinking in a table design than a css design.

I modified the HTML and CSS to this and it does work now in both browsers:[CODE].divtop
{
height: 22px;
width: 264px;
background-image: url(box-top.gif);
}

.divmiddle
{
width: 264px;
background-image: url(box-middle.gif);
}

.divbottom
{
height: 22px;
width: 264px;
background-image: url(box-bottom.gif);
}

.......

<div class="divtop"></div>
<div class="divmiddle">
test1<br />
test2<br />
test3<br />
test4<br />
</div>
<div class="divbottom"></div>[/CODE]

Thanks again Mr. Tim. ?
×

Success!

Help @drallab 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.20,
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,
)...