作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个设计,将在另一个更大的 div 内的一行中的描述文本(和链接)旁边排列一张食谱图片。 (名为 col2)现在图像在描述的下方而不是在它的右侧,如果我想要它的话。谢谢。
.col2{width:60%;
background-color: #FFD6AD;
border-radius:25px
color:#993D00;
padding: 10px;}
font-size: 18px;}
.col2 a {text-decoration:none;
color: #993D00;
font-weight: bold;
font-size:20px;}
.col2 p { max-width:500px;}
.thumb {max-width: 400px;}
.recipe {max-width: 60%;
display: -moz-inline-stack;
display: inline-block;}
使用 HTML
<div class="col2">
<div "info"> Leckeres essen für wehnig Geld. Es gibt viele Gerichte die
ziemlich günstig sind und trozdem schmecken. </div>
<div class="recipe">
<div>
<a href="3bohnen.html"> Chillie aus getrockneten Bohnen </a>
<p>Chillie sin carne, oder vegitarisches Chillie .....) </p>
</div>
<div class="thumb"> <img src="img/sm-chilly.jpg" alt="chilli sin carne">
</div>
</div>
最佳答案
一般的解决方案是将图像向右浮动,并使用 %
限制其宽度。 Online Demo .
<div class="col2">
<div class="thumb">
<img src="img/sm-chilly.jpg" alt="chilli sin carne">
</div>
<div "info">Leckeres essen für wehnig Geld. Es gibt viele Gerichte die ziemlich günstig sind und trozdem schmecken.</div>
<div class="recipe">
<div> <a href="3bohnen.html"> Chillie aus getrockneten Bohnen </a>
<p>Chillie sin carne, oder vegitarisches Chillie .....)</p>
</div>
</div>
<div class="clear"></div>
</div>
使用 CSS:
.col2 {
width:60%;
background-color: #FFD6AD;
border-radius:25px color:#993D00;
padding: 10px;
}
font-size: 18px;
}
.col2 a {
text-decoration:none;
color: #993D00;
font-weight: bold;
font-size:20px;
}
.col2 p {
max-width:500px;
}
.thumb {
float: right;
max-width: 40%;
}
.thumb img {
max-width: 100%;
}
.recipe {
max-width: 60%;
}
.clear {
clear: both;
}
关于html - 如何在一行div中排列2个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33267090/
我是一名优秀的程序员,十分优秀!