html - LI 中带有图标图像的响应式文本宽度

标签 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

最佳答案

最简单的方法是使用 table 布局,其中图像和文本显示为 table-cell

相关 CSS:

li {
  display: table;
}

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

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

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

关于html - LI 中带有图标图像的响应式文本宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26728432/

相关文章:

html - 固定位置 - 宽度错误

jquery - 如何更改 CSS 或 JQuery 中的滚动文本

html - :focus, 后面的链接无法访问移开,div

visual-studio-2010 - 我可以在 Visual Studio 2010 中配置对 HTML5 标记的 "Format Document"支持吗?

CSS:iframe 内的最小宽度响应

javascript - 使用 Html js DOM 还是使用 CSS 进行响应式设计更好?

css - 响应式网站布局入门

javascript - javascript 突变后恢复内部 HTML

css - node.js - 图片和 css 不工作

html - :before 列表的 CSS 增量计数器