css - 一个奇怪的 CSS 问题

标签 css css-float

我有下面的代码 1 和代码 2:

(请在 Google Chrome 8+ 上查看下面的代码)

代码 1:

<!DOCTYPE html>
<meta charset="utf-8">
<title>An HTML5 document</title>
<div style="background:red; height:300px; width:1500px;">
    WWWWWWW<br>WWWWWWW<br>WWWWWWW<br>WWWWWWW<br>WWWWWWW<br>WWWWWWW
    <img src="http://www.swliuxue.com/newindex/uploadfile/201011/18/162266581.jpg" style="float:left;" width="900" height="230">
</div>
<div style="background:green; color:yellow; font-weight:bolder; height:300px; width:1000px;">
    asc aca ascacaaaaaa<img style="vertical-align:top; float:left;" src="http://i3.ytimg.com/vi/F5qniuZG8Rg/default.jpg">Q
</div>

代码 2:

<!DOCTYPE html>
<meta charset="utf-8">
<title>An HTML5 document</title>
<div style="background:red; height:300px; width:1500px;">
    WWWWWWW<br>WWWWWWW<br>WWWWWWW<br>WWWWWWW<br>WWWWWWW<br>WWWWWWW
    <img src="http://www.swliuxue.com/newindex/uploadfile/201011/18/162266581.jpg" style="float:left;" width="900" height="230">
</div>
<div style="background:green; color:yellow; font-weight:bolder; height:300px; width:1000px;">
    asc aca ascacaaaaaab<img style="vertical-align:top; float:left;" src="http://i3.ytimg.com/vi/F5qniuZG8Rg/default.jpg">Q
</div>

我想知道为什么上面的2个代码显示不同。

最佳答案

它们有什么不同?我能看到的唯一区别是“Q”在图片后环绕。这是因为图片向左浮动。

关于css - 一个奇怪的 CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4885372/

相关文章:

html - 如何使容器覆盖内容的全高?

css - Bootstrap 4 beta(最新版)改变条纹表格的颜色

css - 水平滚动画廊在 IE 中缺少滚动条

jquery - 用于后拉伸(stretch)的图像的理想尺寸是多少

jquery - float 选择不显示带有 Chosen Jquery 插件的选择选项

css - 定位这些 DIV 时遇到一些问题

仅使用 float 在调整大小时堆叠的 CSS 列

html - Div定位——如何把一个放在其他的下面

html - 最新的 Chrome : float inside of -webkit-column broken

css - 伪元素中是否可以有伪元素?