简体   繁体   English

如果固定div高度动态变化,要在固定div之后放置div,css发出

[英]To position a div after a fixed div if the fixed div height changes dynamically, css issue

I have a position: fixed div that loads a dynamic image from an external source, the image height changes every time it loads. 我有一个position: fixed div,可从外部源加载动态图像,每次加载时图像高度都会变化。 Now I need to position the next div immediately from where the first div ends. 现在,我需要立即从下一个div位置开始放置下一个div。

Have tried by getting the height during runtime but sometimes it takes time to load and the height sent is not proper. 尝试通过在运行时获取高度来实现,但是有时加载需要时间,并且发送的高度不合适。

Is there any CSS solution to it. 是否有任何CSS解决方案。

Theres many ways to do it, the most optimal would be to use floats (float:left;) 有很多方法可以做到,最理想的方法是使用浮点数(float:left;)

 div{ float:left; } .img{ background-color:red; width:100px; height:100px; } .div{ background-color:lime; width:100px; height:100px; } 
 <div class="img">Dynamic Image</div> <div class="div">Div next to it</div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM