html - Make image scale next to a div inside a div
问题描述
I am creating a webpage where I need to have a two boxes of text right next to each other as long as the other div has content, then the main text will take the width of the whole space.
However, as the text will scale fine, any image will not and will to the the bottom of the small div, leaving a huge empty space between main text and the image.
Is there a simple way to force the images to scale to the side of the inner div or do I need another solution for this?
Thank you in advance! :)
.container {
width: 600px;
}
.long-text {
overflow: hidden;
width: 100%;
background: white;
}
.long-text p {}
.long-text img {
width: auto;
max-height: 400px;
}
.right-column {
width: 200px;
float: right;
background: green;
padding: 5px 0 0 18px;
}
<div class="container">
<div class="long-text">
<div class="right-column">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
</div>
<p>
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
</p>
<img src="https://placeimg.com/640/480/any">
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable
</p>
<p>
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
</div>
JS filddle: https://jsfiddle.net/marginaalivirhe/d8yLko24/8/
解决方案
您还可以为每个分辨率进行布局。
在@media
css 中https://www.w3schools.com/css/css3_mediaqueries.asp
推荐阅读
- polyglot - Polyglot ImportError:无法从“icu”导入名称“Locale”
- arrays - MongoDB - 如何将数组中的 2 个字符串值转换为整数后求和?
- r - mutate 函数显示在数据查看器中创建的新列,但不在环境中的数据框中
- firebase - flutter firebase phone auth error a security net token was pass but no matching sha-256 was registered in the firebase console
- node.js - 如何在不获取另一个随机数的情况下从函数中获取随机数?
- firebase - 什么是 Firebase Analytics 日志事件(未设置)关键字
- android - 如何将我的手机摄像头连接到我的电脑
- scala - Kafka 流:SessionWindowedSerde 与 TimeWindowedSerde。模棱两可的隐含值
- javascript - (React.js) 嵌套 useContext (全局 > 小组件)
- node.js - 安装服务节点窗口后找不到服务