LI中的响应文本宽度与图标图像

时间:2014-11-04 05:39:20

标签: html css responsive-design sass

我有一个我想用拇指图标显示的产品列表 在每个项目的左侧。

如何在不包装的情况下在右侧显示产品说明 小屏幕上的文字。

HTML

<ul>
    <li class="cf">
      <span id="customizeImage1" class="product-customize-image"></span>
      <div class="product-menu-txt">
        <a href="/Product/Customize/769497">Friend Maker - Serves 8-10</a>
        ($14.99)<br>
        6 Donuts<br>
        6 Bagel &amp; Cream Cheese - 1 (8oz) tub<br>
        An assortment of our most favored varieties.
      </div>
    </li>
  </ul>

CSS

* {
  margin:0;
  padding:0;
  font-family: Tahoma,Sans-Serif;
}

.cf:before,
.cf:after {
    content: " "; /* 1 */
    display: table; /* 2 */
}

.cf:after {
    clear: both;
}

/**
 * For IE 6/7 only
 * Include this rule to trigger hasLayout and contain floats.
 */
.cf {
    *zoom: 1;
}

li {
  width: 100%;
  list-style-type: none;
  padding: 10px 0;
}

.product-customize-image {
  width:120px;
  height:120px;
  background:red;
  display:block;
  float:left;
  margin: 0 10px;
}

.product-menu-txt {
  float: left;
  width: 50%;
}

http://jsbin.com/girum/4/edit

wrapped text on smaller screen

Text that fits the width of the row

1 个答案:

答案 0 :(得分:1)

最简单的方法是使用table布局,图片和文字显示为table-cell s。

相关CSS

li {
  display: table;
}

.product-customize-image {
  display:table-cell;
}

.product-menu-txt {
  display: table-cell;
  padding-left: 8px;
}

演示http://jsbin.com/banuvoharo/1/