Forum Moderators: not2easy

Message Too Old, No Replies

custom boxes

         

webMASTERP

3:00 pm on Jun 29, 2004 (gmt 0)

10+ Year Member



After a say of screwing around, i finally understood and figured out how to make custom graphic borders around my DIVs, similar to what i was doing with tables.
Using this article as my main tutorial
[****.com...]

There's only one problem with it. I can't set the background color of the footer, since that property is aleady taken up by the image bg. And i don't have any other hooks in there. Is there a good way to do it without adding in more DIV? I am not 100% happy with the way my HTML look already, and i don't want to add any more stuff to it.
Here's the code. The graphics are sliced up the same way as they are in the tutorial above


<!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>
<title>CSS Design: Creating Custom Corners &amp; Borders: A List Apart: Looks like we're finally there!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="screen">
div.Article
{
width:35%;
background: url(images/element_topleft.gif) top left no-repeat;
}
div.Article h3
{
background: url(images/element_topright.gif) top right no-repeat;
font: 18px Geneva, Arial, Helvetica, sans-serif;
color: white;
font-weight: bold;
margin: 0px;
padding-left: 15px;
height:22px;
}
div.ArticleBody
{
background: url(images/element_rightborder.gif) top right repeat-y;
margin:0px;
padding: 0px;
}
div.ArticleBody p
{
font: 14px Geneva, Arial, Helvetica, sans-serif;
background: green;
padding-left: 5px;
padding-right: 5px;
margin-left: 5px;
margin-right:5px;
margin-top:0px;
margin-bottom:0px;
}
div.ArticleFooter
{
margin: 0px;
background: url(images/element_bottomleft.gif) bottom left no-repeat;

}
div.ArticleFooter p
{
background: url(images/element_bottomright.gif) bottom right no-repeat;
margin: 0px;
text-align: right;
padding-right:10px;
padding-bottom:5px;
font-style: italic;
font-size: 12px;
}
</style>
</head>
<body>
<div class="Article">
<DIV class="ArticleHeader">
<h3>Article Header</h3>
</DIV>

<div class="ArticleBody">
<p>
A few paragraphs of article text.<br />
A few paragraphs of article text.
</p>

<p>
A few paragraphs of article text.<br />
A few paragraphs of article text.
</p>
</div>

<div class="ArticleFooter">
<p>Article Footer</p>
</div>
</div>
</body>
</html>

createErrorMsg

4:25 pm on Jun 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



div.ArticleFooter p
{
background: url(images/element_bottomright.gif) bottom right no-repeat;

The simple answer lies in the shorthand for the background attribute, which goes:

background: color image position repeat;

So, to add a white background (which will lie behind your image, more in a moment) your new style rule says:

div.ArticleFooter p {
background: #fff url(images/element_bottomright.gif) bottom right no-repeat;
}

That said, I suspect that this may not give you the results you want, primarily because Soren Madsen's technique involves images as the backgrounds in your various <divs>. Unless you've drastically swayed from his procedure, the only way to change the INNER background color of the footer (or any other peice inside the custom rounded corners) is to change the color of the background image in your image editor, then re-export it over the old one.

In other words, changing the background with CSS will change the color BEHIND the image, but in MAdsen;s layout, the color of your 'working' area (text location, et al) is determined by the image itself?

Capisci?

webMASTERP

5:32 pm on Jun 29, 2004 (gmt 0)

10+ Year Member



yeah, it didn't help, it just placed the solid color over my background. I'd rather not change the image, since i want to be able to change the BG color on the fly, without having to go any graphic editing.
And i would settle for putting an image in the background if IE was able to handle transperancy the right way.
Thanks for your help though

createErrorMsg

6:44 pm on Jun 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now that I think of it, there is another possibility for you, provided you don't mind losing the drop shadow on your rounded boxes (assuming, of course, that you used images similar to Madsen's in your layout). If you can live without the drop shadow, rounded corners with manipulable backgrounds is actually pretty easy.

Since I learned the technique from a(nother) A List Apart article, I'll just direct you there instead of trying to explain it here. The article is called Mountaintop COrners by Dan Cederholm. Specifically, you want the section on Transparent Peaks.

Check it out and let me know if it does the trick.

webMASTERP

11:30 am on Jun 30, 2004 (gmt 0)

10+ Year Member



i read over it and it's a bit confusing at the moment, i'll need to try it out
but i can't loose the border on the right, it's a part of my design

createErrorMsg

11:43 am on Jun 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then all I can think to do, if you need to switch background colors on the fly, is to create multiple sets of the sliced up background images (blech!) saved by color name (ie, topright_red.gif, etc), then use javascript to swap the image files in the stylesheet rule declarations.

That's very doable, actually (I may do it myself!). User could get a simple form <option> menu, select a color and the page reloads with the new images...

Other than that, I don't think it's possible because of the nature of the design (you could try making the white inner part of the image transparent, but i seem to remember trying that and discovering that it doesn't work.)

webMASTERP

11:59 am on Jul 1, 2004 (gmt 0)

10+ Year Member



i would really rather not do that, but i might have to
i am going to experiment a little more with it