在底部,您有完整的标记。
如果我有保证金:0;在样式声明“#sweden dd”中,文本将围绕向左浮动的图像。这很容易理解,但是如果我更改“#sweden dd”中的边距样式,而不是 margin:0; 我设置边距:0 0 0 98p;文本将在列中的图像旁边排列。
所以我真正无法理解的是,为什么当我指定 margin:0 0 0 98p; 时文本会排成一列?我知道我的边距样式中的最后一个数字是左边距,所以这不是问题。
//start markup causing text to surround the image that is float left
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body
{
font-family:Arial, sans-serif;
font-size:small;
}
#sweden
{
float:left;
width:300px;
padding:10px 0;
border:2px solid #C8CDD2;
background:url(img/bg.gif)no-repeat top left;
}
#sweden dl /* block element */
{
float:left;
margin:10px 20px;
padding:0;
}
#sweden dt /* block element */
{
float:right;
margin:0;
padding:0;
font-size:130%;
letter-spacing:1px;
color:#627081;
width:162px;
background:red;
}
#sweden dd
{
margin:0; /* This will surround the image with text */
/* margin:0 0 0 98p; This will keep the text beside the image in a column. */
padding:0;
font-size:85%;
line-height:1.5em;
color:#666;
background:yellow;
}
#sweden dd.img img
{
float:left;
margin: 0 8px 0 0;
padding:4px;
border:1px solid #D9E0E6;
border-bottom-color:#C8CDD2;
border-right-color:#C8CDD2;
background:#fff;
}
#sweden dl dd.img
{
margin:0;
}
</style>
<meta charset="utf-8" />
<title>Chapter 3</title>
</head>
<body>
<div id="sweden">
<dl>
<dt>Stockholm</dt>
<dd class="img"><img src="img/gamlastan.jpg" width="80" height="80"
alt="Gamla Stan" /></dd>
<dd>This was taken in Gamla Stan.This was taken in Gamla Stan.
This was taken in Gamla. This was taken in Gamla Stan.
This was taken in Gamla Stan.This was taken in Gamla Stan.
This was taken in Gamla. This was taken in Gamla Stan.
This was taken in Gamla Stan.This was taken in Gamla Stan.
This was taken in Gamla Stan. This was taken in Gamla Stan.
This was taken in Gamla Stan.This was taken in Gamla Stan.
This was taken in Gamla Stan.This was taken in Gamla Stan.
This was taken in Gamla Stan.This was taken in Gamla Stan.
This was taken in Gamla Stan.This was taken in Gamla Stan.</dd>
</dl>
</div>
</body>
</html>
//Tony