How can a float design achieve such a table result?

I’m usually a web technology enthusiast, and I’m all for design without tables, but right now, it annoys me a little.: /

I am trying to achieve something that would be extremely easy with tables, but that seems too complicated / impossible using floating elements. Take a look at the following:

+-----------------+ +-------+
|                 | |       |
|    #contents    | | #info |
|                 | |       |
|                 | +-------+
+-----------------+

Where #infohas a fixed width and should be floating right on #contents. #contentsmust take whatever remains of the width.

In a simple design, where both #contents, and #info, are present , it is not too complicated. They have a fixed width, have a property float:leftand are very well suited.

However, some pages #infowill not be present. In this case, it obviously #contentsdoes not scale to fit the entire page.

The most obvious solution was to give a #contentsfixed width so that it scales, and change #infoto float:right. The past minor other changes that he needed did not have the desired behavior, as he breaks the column layout when #contentshigher than #info:

+-----------------+ +-------+
|                 | |       |
|    #contents    | | #info |
|                 | |       |
|                 | +-------+
|                 +---------+
|                           |
+---------------------------+

Worse, inside #contentsthere are others <div>with a set of properties border-bottom, and the border goes directly through the #infofollowing way too:

+-----------------+ +-------+
|                 | |       |
|    #contents    | | #info |
|-----------------|-|-------|
|                 | +-------+
|                 +---------+
|                           |
+---------------------------+

, , #info , #contents, #contents #info , ?

, #contents, #info:

+-----------------+ +-------+
|                 | |       |
|    #contents    | | #info |
|-----------------| |       |
|                 | +-------+
|-----------------|
|                 |
+-----------------+

, #contents:

+---------------------------+
|         #contents         |
|---------------------------|
|                           |
|---------------------------|
|                           |
+---------------------------+

, . .

+3
2

- , . Internet Explorer ( , 6), .

#info, float:right, #contents overflow:hidden. .

0

div #content, , , , #info . #info, - #content, #content , #info, .

0

Source: https://habr.com/ru/post/1734648/


All Articles