Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
一个奇怪的CSS问题_Css_Css Float - Fatal编程技术网

一个奇怪的CSS问题

一个奇怪的CSS问题,css,css-float,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>WWWWW

我有以下代码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>

HTML5文档
WWWWWWW
WWWWWWWWW
WWWWWWWWW
WWWWWWWWW
阿卡阿卡阿卡阿卡
代码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>

HTML5文档
WWWWWWW
WWWWWWWWW
WWWWWWWWW
WWWWWWWWW
asc aca ASCACAAAABQ

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

它们在哪些方面不同?我能看到的唯一区别是“Q”在图片后面被包裹起来。这是因为图片向左浮动

字体大小:粗体;这是真正的css规则吗?如果不是,那么这就是你的问题,#1和#2之间的唯一区别是左浮动图像前的文本<代码>asc aca ASCACAAAAA!=这是真的。这比大胆还要大胆!为什么第二个图像显示在代码1的第二行?(与代码2相比)正如我在上一篇文章中所说:修复html!(doctype、html、head、body、closed标记)等。。。您将能够调试css。这个HTML不应该工作,浏览器很乐意接受它。我想知道为什么在代码1中第二个图像显示在
Q
之后的第二行?我认为第二个应该显示在
ascacaaaaa
的左侧,就像代码2中的情况一样。谢谢这是因为文本行的长度不同,所以它是换行的。试着把1和2中的线条变长,你会看到。。。