Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to places two divs in one row: one fixed, other is stretched

Tags:

html

I need two div boxes: one at left side with fixed width, and other on the right side of first and it should stretch to right side. How to do this?

/-- 30px --//------ * -------/
|          |                 |
|          |                 |
like image 660
user283010 Avatar asked Mar 01 '10 16:03

user283010


2 Answers

<div style="left:0;width:30px;"></div>
<div style="left:30px;right:0;"></div>

You may need to make them absolute positioned and the parent relative.

like image 191
Tor Valamo Avatar answered Oct 12 '22 03:10

Tor Valamo


Better not to use absolute position, since you may want to place it within other elements. That's what works for me:

<div>
  <div style="float: left; width: 30px">1</div>
  <div>2</div>
</div>
like image 44
Sergiy Belozorov Avatar answered Oct 12 '22 03:10

Sergiy Belozorov