0

I'm doing a layout for an online shop. I wanna have a two-column layout, with the two div at the same height, but not for all the divs, but only the two on the same row. the problem is, that the pictures do not all have the same height, so sometimes the left div is higher which makes the next div come on the right side (float: left). Is there any way to solved it without the same height for all divs?

HTML:

<div id="inhalt">
  <div class="listext">Title<br /><br />
    <div><span class="listebild">picture</span>text</div>
    <div class="listepreis">price</div>
    <div class="listemenge">formular stuff</div>
  </div>

  <div class="listext">Title<br /><br />
    <div><span class="listebild">picture</span>text</div>
    <div class="listepreis">price</div>
    <div class="listemenge">formular stuff</div>
  </div>

  <div class="listext">Title<br /><br />
    <div><span class="listebild">picture</span>text</div>
    <div class="listepreis">price</div>
    <div class="listemenge">formular stuff</div>
  </div>

CSS:
#inhalt
  {
 width: 600px;
 float: right;
 margin-top: 1px;
 margin-left: 1px;
 margin-bottom:20px;
 padding: 10px 10px 20px;
 background-image: url(http://www.kostuemkaiser.ch/images/bg_3.png);
 border-bottom-left-radius: 20px;
 border-bottom-right-radius: 20px;
 }  `
.listebild {
    width: 68px;
    float: left;
    text-align:left;
    margin-bottom:25px;
 }


 .listext {width: 300px;
    float: left;
    text-align:left;
    margin-bottom:25px;
    min-height:170px;
 }

 .listepreis {
    float: left;
    text-align:left;
    padding-top: 20px;
    margin-right:15px;
    font-size:12px;
 }

 .listemenge {
    float: left;
    font-size:12px;
    text-align:left;
    padding-top: 17px;
 }

Is there a way to make the height smaller if the pictures of both divs on the same row is small? I do need this "single div" style, because the data will be filled in automaticaly. This is how it looks with min-height 170px: the problem if I take it away, sometimes the left div squeezes in at the right side... Thanx for ideas

4

2 に答える 2

0

左右のビットを揃えてほしいとのことですが、質問とレイアウトからはそれを得ることができなかったので、代わりに使用方法を示す POC を作成しました。

display: table;

display: table-cell;

問題を解決できます: http://jsfiddle.net/B2k2a/1/

于 2013-11-10T15:38:43.180 に答える