Jump to content

make a div bigger than its container


Renlok

Recommended Posts

Sorry i wasnt sure to post this in HTML or CSS

 

But what i want is to try and make the effect in the attachment so it looks like its being wrapped around the page. And i cant add the hangover bits with absolute divs because the part above it will change size as its dynamically generated.

 

So i was wondering if its possible to make a div bigger than its container? or if theres a better way

 

[attachment deleted by admin]

Link to comment
Share on other sites

This is what I have done for a similar theme:

 

HTML:

<div id="wrapper">
  //page contents
</div>
<div id="header_wrapper">
  <div id="header">
    // header contents
  </div>
</div>

 

CSS:

#wrapper
{
  width:800px;
  padding-top:300px; // set this to enough space for the entire header
  margin:0 auto;
}
#header_wrapper
{
  position:absolute;
  top:100px;
  height:200px; (top positioning plus height cannot be more than the top padding left on the body)
}

#header
{
  width:900px;
  margin:0 auto;
}

Link to comment
Share on other sites

This can easily be achieved by using negative margins (as long as the parent is not set to overflow:hidden;)

 

example here

 

CSS

#parent {
	width:800px;
	background:red;
	margin:0 auto;
	min-height:1000px;  /** just for show **/
	padding:100px 0 0 0;	/** just for show **/
}

#child {
	margin:0 -20px;
	background:blue;
	min-height:100px;	/** just for show **/
}

 

HTML

<div id="parent">

<div id="child">

</div>

</div>

Link to comment
Share on other sites

  • 2 weeks later...
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.