Jump to content

Hiding the top of a background image!


mattal999

Recommended Posts

Hi guys,

 

I have this css:

 

<style type="text/css">
/* Show only to IE PC */
* html .boxhead h2 {
height: 1%;
} 
/* For IE 5 PC */

body {
background: url(images/background.jpg);
font-family: Tahoma;
}

.logo {
margin: 0 auto;
padding-top: 20px;
width: 50em;
}

.logo .padding {
padding-left: 0.8em;
}

.sidebox {
margin: 0 auto;
width: 50em;
background: transparent url(images/sbbody-r.png) no-repeat bottom right;
font-size: 100%;
}

.boxhead {
background: transparent url(images/sbhead-r.png) no-repeat top right;
margin: 0;
padding: 0;
text-align: left;
}

.boxhead ul {
background: transparent url(images/sbhead-l.png) no-repeat top left;
margin: 0;
padding: 20px 25px 10px;
color: #000000; 
font-size: 0.7em; 
font-family: Tahoma;
line-height: 1em;
}

.boxhead ul a {
font-weight: bold;
text-decoration: none;
color: #000000;
}

.boxhead ul a:hover {
color: #3d3d3d;
}

.boxbody {
background: transparent url(images/sbbody-l.png) no-repeat bottom left;
margin: 0;
padding: 1px 25px 15px;
font-family: Tahoma;
font-size: 0.8em;
}
</style>

 

And this HTML:

 

<div class="sidebox">
<div class="boxhead">Home</div>
<div class="boxbody">
	<p>This is a short sample paragraph.</p>
	<p>And another one.</p>
</div>
</div>

 

Now this works OK, all apart from the fact that the images are transparent, and the sbbody-r.png image messes up, because it is too high and continues under the top bar. Here is the example:

 

resultt.jpg

 

Any ideas on how to clip the top of the sbbody-r.png image in the div to make it stop before it goes too high?

 

Thanks.

Link to comment
Share on other sites

looks to me like your image has a top white border have a look at it in an image viewer i recommend irfan view as it has a black background easy to see white borders on.

 

You can't really hide the top of an image you need to remake the image with the correct background color

Link to comment
Share on other sites

Clipping background images (and multiple background images) is the holy grail of CSS3. However, CSS3 is not supported for the most part, and therefore it is not a feasible solution at this time. You will need to redo the original graphic.

Link to comment
Share on other sites

I cannot resize the image, as I need it to take up the whole box no matter the height. I don't think you quite understand. I am using this code as a base for the box.

 

The white part is the part of sbbody-r.png that is taking up the whole div. Basically, because it is aligned to the bottom right, if sbbody-r is longer than that height (which it always is, and always will be), then you can see it below the top header bar. If I am not making sense, I can put up a test page.

Link to comment
Share on other sites

But if I felt compelled to do it this way, is there a quick fix? As of now, I cannot find a way to make rounded cornered boxes with transparency that can support a header box too. If you could give me a quick example based on my webpage layout, then I will look into it further.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.