CSS Background image question

Status
Not open for further replies.

Stray Toaster

Ars Tribunus Militum
2,292
Subscriptor++
I am attempting to construct a roll-over pop-up box via HTML and CSS. The box is rectagular with an arrow sticking off the left side of it. It needs to scale height based on how much content is in it, and it has a drop-shadow with alpha transparency.

Here is what I have attempted to due:

One big div to contain everyting, within it is 5 other divs to construct the box from .png's with alpha.

since it is fixed width I have it built as following:

1) Top PNG with the top edge drop shadow 159px x 6px
2) body png with the left and right hand drop shadow, set to repeat Y
3) arrow PNG, which floats in the middle of the big div over the body
4) bottom PNG, with the bottom edge drop shadow
5) an empty div with the approrpiate padding to contain the text.

Now, the issue I am running into, is the top and bottom edge PNGs are floating over the repeating background image of the body and since they all have alpha, I can see body PNG running all the way to the top and bottom, ruining the corners of the box.

I have been trying to figure out how to either make the body div start below the top dive and have the bottom div below it, or make the background image start 5px down from the top of the div and end 5px before it ends.

I'm at a loss right now... Any ideas on how to fix this? And, it is not possible to do absolute positioning on this stuff, or it would be too easy.

here is the HTML
Code:
<div id="flyoutBox">
	<div class="flyoutBody">
		<div class="flyoutTop">
			<div class="flyoutArrow">
				<div class="flyoutBase">
					<div class="flyoutText">
            Lorem Ipsum is 
                   </div>
				</div>            
			</div>
		</div>
	</div>	
</div>

and the CSS
Code:
#flyoutBox {
	position: relative;
	left: 3px;
	top: 3px;
	margin-right: 3px;
	margin-bottom: 3px;
	width: 159px;
	text-align: left;
}

#flyoutBox .flyoutTop {
    background-image: url(/html//civis/threads/images/flyout_top.png);
	background-position: top left;
	background-repeat: no-repeat;
}

#flyoutBox  .flyoutBody {
    background-image: url(/html//civis/threads/images/flyout_body.png);
    background-position: center;
	background-repeat: repeat-y;
	
}

#flyoutBox  .flyoutArrow {
    background-image: url(/html//civis/threads/images/flyout_arrow.png);
	background-position: center;
	background-repeat: no-repeat;

}
#flyoutBox .flyoutBase {
    background-image: url(/html//civis/threads/images/flyout_base.png);
	background-repeat: no-repeat;
	background-position: bottom left;
}

#flyoutBox .flyoutText {
	font-family: arial, helvetica, sans-serif;
    font-size: 0.8em;
	color: #999999;
	text-align: left;
	padding-left: 26px;
	padding-top: 15px;
	padding-bottom: 15px;
	padding-right: 15px;
	
}
 

Stray Toaster

Ars Tribunus Militum
2,292
Subscriptor++
I figured out a solution.

Basically what I did was un-tie all the div classes from the div id flyout, and then re-arranged the heirarchy so the it goes:

Top
Base
Body
Arrow
Text

I then added padding to the base, which effected how large the body div was, effectively forcing it to start after the top PNG and end before the bottom.

here is the final code, if anyone cares:
Code:
<!-- Start flyout box -->
<div id="flyoutBox"> <!-- The Div ID containing the whole thing -->
	<div class="flyoutTop"> <!-- Top edge gradient -->
  		<div class="flyoutBase"> <!-- Bottom edge gradient, with padding to constrain the body background -->
	 		<div class="flyoutBody"> <!-- this makes up the left and right hand gradients -->
				<div class="flyoutArrow"> <!-- the arrow floats on top and dead center -->
					<div class="flyoutText"> <!-- The text is on the top of everything -->
            Lorem Ipsum is 
            		</div>
				</div>            
			</div>
		</div>
	</div>	
</div>
<!-- End flyout box -->

CSS:
Code:
#flyoutBox {
	position: relative;
	width: 159px;
	text-align: left;
	
}

.flyoutTop {
    background-image: url(/html//civis/threads/images/flyout_top.png);
	background-position: top left;
	background-repeat: no-repeat;
	width: 159px;	
}
.flyoutBase {
    background-image: url(/html//civis/threads/images/flyout_base.png);
	background-repeat: no-repeat;
	background-position: bottom left;
	padding-top: 6px;
	padding-bottom: 5px;

}

.flyoutBody {
    background-image: url(/html//civis/threads/images/flyout_body.png);
    background-position: center;
	background-repeat: repeat-y;
}

.flyoutArrow {
    background-image: url(/html//civis/threads/images/flyout_arrow.png);
	background-position: center;
	background-repeat: no-repeat;

}

.flyoutText {
	font-family: arial, helvetica, sans-serif;
    font-size: 0.8em;
	color: #999999;
	text-align: left;
	padding-left: 26px;
	padding-top: 5px;
	padding-bottom: 5px;
	padding-right: 10px;
	display: inline-block 
	
}
 
Status
Not open for further replies.