css - 使用内联 block 的响应式设计

标签 css

我只是使用内联 block 设计了一个 HTML 页面,使其具有响应性。我将所有 block 形式的图像和文本设置为内联 block ,但文本 block 被移动到图像 block 下,我如何设置 CSS 并将文本 block 放在图像 block 的右边?

演示:http://jsfiddle.net/yckelvin/ar1f3uz5/

HTML代码

<div class="item-row">
<div class="item-li"><img src="https://3.bp.blogspot.com/-t9e7S8huhaQ/VBMVN6CbNGI/AAAAAAAAA14/02am46_jiJM/s1600/Big_smile.png" width="150" height="150" /></div>
<div class="item-desc" ><h1>Item 1</h1>
Description Description Description Description Description Description Description Description Description Description </div>
</div>

<div class="item-row item-indent-row">
<div class="item-li"><img src="https://3.bp.blogspot.com/-t9e7S8huhaQ/VBMVN6CbNGI/AAAAAAAAA14/02am46_jiJM/s1600/Big_smile.png" width="150" height="150" /></div>
<div class="item-desc"><h1>Item 2</h1>
Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description </div>
</div>

CSS 代码

.item-row { display: block; width: 100%; padding: 30px; background-color: rgba(0,0,0,0.1); }
.item-indent-row { padding-left: 150px; }
.item-li {display: inline-block; width:50px; background-color: rgba(255,255,0,0.1); }
.item-desc {display: inline-block; background-color: rgba(0,0,255,0.1); padding-left: 0px;}

真实样本

元素 1

说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明


元素 2

说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明说明

最佳答案

.item-desc {
    display:block;
    width:200px; 
    /*Or whatever width you wanted the description 
      to be. Just make sure it's not too wide to fit on the same line
    */
    float:left; 
    background-color: rgba(0,0,255,0.1); 
    padding-left: 0px;
 }

关于css - 使用内联 block 的响应式设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26112512/

相关文章:

html - 设置div全宽并修复

html - 带有响应式 css 的 CSS 页脚

javascript - 从右向左调整 div 大小

html - 外包 css 属性不起作用

css - Webapp 不加载图像

html - 将文本包装在 `<li>` 元素内

c# - 使 div 元素与 PDF 输出中的 A4 大小相同

javascript - 使用 javascript 更新 z-index 赋值中的左侧无效

javascript - 将鼠标悬停在滚动列表中的图片上

jquery - 如何向动态创建的图像添加边框图像?