Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

one div with 100% width and two fixed divs in one line

Tags:

css

I need three divs in one line.

One is size 200px, second 300px and last div should be what's left.

Why is my last div in a new row?

<div style="float: left; width: 200px; background: #223355">a</div>
<div style="float: left; width: 300px; background: #223344">b</div>
<div style="float: left; width: 100%; background: #334455">c</div>
like image 346
lolalola Avatar asked Apr 21 '11 20:04

lolalola


People also ask

How do I show two divs on the same line?

The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.

How do you make a div 100 width?

What you could do is set your div to be position: absolute so your div is independent of the rest of the layout. Then say width: 100% to have it fill the screen width. Now just use margin-left: 30px (or whatever px you need) and you should be done.

Is a div 100% width by default?

auto automatically computes the width such that the total width of the div fits the parent, but setting 100% will force the content alone to 100%, meaning the padding etc. will stick out of the div, making it larger than the parent. so setting the 'width' to 'auto' would be better? Yes, but that's the default anyway.

How do I put 3 divs in a row?

Three or more different div can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side.


2 Answers

AS others have said 100% is 100% of page width.. but I disagree with user who says it can't be done with 'plain' CSS

<div style="float: left; width: 200px; background: #223355">a</div>
<div style="float: left; width: 300px; background: #223344">b</div>
<div style="overflow: hidden; background: #334455">c</div>
like image 96
clairesuzy Avatar answered Sep 22 '22 05:09

clairesuzy


Shouldn't you just have to remove the float:left; on the last div for it to work?

like image 44
Andre Backlund Avatar answered Sep 22 '22 05:09

Andre Backlund