Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get an image to spill over the edge of a div

Tags:

html

css

So, I'm getting married. Hooray!

I'm building a website for the event and HTML/CSS isn't my normal area of expertise.

I've got the site sliced and diced, and most of the important structure laid out in divs.

One thing I'm not sure of though, is that the design calls for an image to spill over both edges of the wrapper. What's the best way to do that in HTML/CSS? Or should I make the wrapper the full image width wide and make another container inside for the other content?

Thanks for your help!

  • Here's the design comp: website_comp.jpg
  • Here's the image that needs to spill over the div: ribbon.png
  • Here's what the site looks like now: DierksAndEmster.com
like image 756
John Avatar asked Mar 06 '11 20:03

John


People also ask

How do I stretch an image in HTML?

If your image doesn't fit the layout, you can resize it in the HTML. One of the simplest ways to resize an image in the HTML is using the height and width attributes on the img tag. These values specify the height and width of the image element. The values are set in px i.e. CSS pixels.

How do I stop images from moving outside of div?

Try giving an overflow:hidden to the div. Show activity on this post. add overflow:hidden; to your div style.


2 Answers

add position:relative and overflow:visible for your #container. Then modify your menu like the following:

#menu {
    background: url("http://www.dierksandemster.com/wp/wp-content/themes/et-starter-1-4/images/ribbon.png") repeat scroll 0 0 transparent;
    color: black;
    display: block;
    float: left;
    font-family: 'Walter Turncoat',arial,serif;
    font-size: 20px;
    height: 93px;
    left: -71px;
    line-height: 22px;
    position: absolute;
    width: 942px;
}
like image 68
Sotiris Avatar answered Oct 05 '22 03:10

Sotiris


You could attempt to position the image with position: absolute. Another way could be to use three columns. (~50px wide left column, main area, ~50px wide right column).

You could also take a look how csswizardry has done this, it's a bit advanced though, but might be helpful: http://csswizardry.com/demos/css-powered-ribbons/

Last but not least, if you wan't to be quick and know the navigation panel that has the fancy ribbons never changes place, why not just make a big background image and build the site on top of it? :)

like image 37
red Avatar answered Oct 05 '22 05:10

red