Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在页面上为尺寸直到运行时未知的图像分配空间的最佳方法是什么,最好不要超出 HTML 和 CSS?
这个问题很笼统。
如果您事先不知道图像尺寸,那么一种安全的方法是让图像浮动(向左或向右)文本。
如果图像将被放置在表格单元格中,请确保该单元格是可扩展的(即您没有指定宽度和诸如 之类的东西overflow: hidden)。
overflow: hidden