Y
Y
Yaraife2011-09-27 11:40:28
css
Yaraife, 2011-09-27 11:40:28

Fully rubber layout in DIV (there are 2 solutions)

Is there any possibility, without using scripts, to do this:

[Rubber DIV, stretches from the content][Rubber div that takes up all the remaining space]

More: You need to make one of the blocks take up as much space as it needs to display all of your inline and block elements (Are there none? ok, width 0). And the other block stretched to the full width of the remaining space.

Similar but not suitable options:

Reason: fixed width of the first div
<div style="width:200px;float:left;">Первый див</div>
<div style="margin-left:200px;width:100%;">Второй див</div>


Reason: The second div gets under the first
<div style="float:left;">Первый див</div><div>Второй див</div>


Reason: Works exactly as expected, but IE6 doesn't understand this value.
<div style="display:table;">
<div style="display:table-cell;">Первый див</div><div style="display:table-cell;">Второй див</div>
</div>


Decision:

GruZZ and tenbits flack.ru/2008/08/26/semantic-coding-howto-6/
Method: float:left; and overflow:hidden;
<div id="All">
  <div id="div1">One</div>
  <div id="div2"> Two</div>
</div>

*{
  padding:0px;
  margin:0px;
}
#All{
 font-size: 2em;
 width:100%;
} 
#div1{
 float:left;
}
#div2{
 overflow:hidden;
 background: yellow;
}

MTonly tanalin.com/projects/display-table-htc/
Way: emulate display:table property; using the .htc extension

Answer the question

In order to leave comments, you need to log in

8 answer(s)
N
Nikolai Sadovnikov, 2011-09-27
@Yaraife

flack.ru/2008/08/26/semantic-coding-howto-6/ ?

D
Dmitry Sidorov, 2011-09-27
@Doomsday_nxt

<div style="float:left;">Первый див</div><div>Второй див</div>

D
Dmitry Boyko, 2011-09-27
@Bo_bda

#div1 {
float: left;
background: blue
color:white;
height:100%;
width:200px;
}
#div2{
height: 100%;
background:yellow;
color: blue;
margin-right:200px;
width:100%;
}
#all{
width:100%;
}
HTML
<div id="all">
<div id="div1"> Content1 </div>
<div id="div2">Content2 </div>
</div>

M
MT, 2011-09-27
@MTonly

If the table view as such solves the problem, then take a closer look at display: table emulation for IE6/7 .

I
int03e, 2011-09-27
@int03e

So what's the question?) cssdesk.com/TQbwx

A
Alexander Keith, 2011-09-27
@tenbits

Just as an option, via display:table-*: cssdesk .

D
Dmitry Boyko, 2011-09-27
@Bo_bda

post a picture of the layout, we will help in any way we can

D
Dmitry Boyko, 2011-09-27
@Bo_bda

cssdesk with all due respect to what was written above, I don’t think it’s necessary to pervert like that ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question