Stacking DIVs on top of each other?

Position the outer div however you want, then position the inner divs using absolute. They’ll all stack up. .inner { position: absolute; } <div class=”outer”> <div class=”inner”>1</div> <div class=”inner”>2</div> <div class=”inner”>3</div> <div class=”inner”>4</div> </div>

How to fix Internet explorer 7 bug when using percentage widths for layout?

The problem is sub-pixel rounding. When you are designing with percentages there will be times that the math doesn’t result in full pixels (70% of 721px is 504.7px). 721 is arbitrary, but using percentages you’ll run into arbitrary numbers. There’s no avoiding that. Most browsers figure out a rounding solution for you that doesn’t break … Read more

How to horizontally center a floating element of a variable width?

Assuming the element which is floated and will be centered is a div with an id=”content” … <body> <div id=”wrap”> <div id=”content”> This will be centered </div> </div> </body> And apply the following CSS: #wrap { float: left; position: relative; left: 50%; } #content { float: left; position: relative; left: -50%; } Here is a … Read more

Creating CSS3 Circles connected by lines

You can achieve this effect with no additional markup using pseudo-elements and the adjacent sibling selector (~): li { width: 2em; height: 2em; text-align: center; line-height: 2em; border-radius: 1em; background: dodgerblue; margin: 0 1em; display: inline-block; color: white; position: relative; } li::before{ content: ”; position: absolute; top: .9em; left: -4em; width: 4em; height: .2em; background: … Read more

Floating Div Over An Image

Never fails, once I post the question to SO, I get some enlightening “aha” moment and figure it out. The solution: .container { border: 1px solid #DDDDDD; width: 200px; height: 200px; position: relative; } .tag { float: left; position: absolute; left: 0px; top: 0px; z-index: 1000; background-color: #92AD40; padding: 5px; color: #FFFFFF; font-weight: bold; } … Read more

CSS to stop text wrapping under image

Very simple answer for this problem that seems to catch a lot of people: <img src=”https://stackoverflow.com/questions/11411219/url-to-image”> <p>Nullam id dolor id nibh ultricies vehicula ut id elit.</p> img { float: left; } p { overflow: hidden; } See example: http://jsfiddle.net/vandigroup/upKGe/132/