在</p> <div> </div>中将图片浮动到<p>的右侧

时间:2013-08-01 18:53:27

标签: image html css-float

我正在尝试在网页上创建一个图表,其中每个条目都被编码为包含<p>元素的div,以编号条目,最左边的条目和旁边的图片。但是,当我尝试这段代码时:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD\xhtml1-strict.dtd">
<html xmlns="hhtp://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title></title>
        <style>
            .entry {
                background-color: #99d699;
                width: 600px;
                height: auto;
                margin-left: auto;
                margin-right: auto;
                padding: 1px;
                border-color: #808080;
                border-width: 2px;
                border-bottom-style: solid;
                position: relative;
                overflow: hidden;
            }
            .entry p {
                color: white;
                font-weight: bold;
                font-size: 30px;
                margin-top: 15px;
                margin-bottom: 15px;
                margin-left: 10px;
            }
            .art {
                width: 80px;
                height: 80px;
                margin-top: auto;
                margin-bottom: auto;
                margin-left: 10px;
                float: left;
                overflow: hidden;
            }
        </style>
    </head>
    <body style="background-color: #D6DDD6;">

        <div class="entry">
            <p>
                1
            </p>
            <img class="art" src="http://wvs.topleftpixel.com/photos/2008/04/Dundas_Square_Pano_Fisheye_tunnel_crop.jpg"     alt="Random pic" />
        </div>
    </body>
</html>

......图片最后在段落下方。如何将图像清晰地放在段落的右侧?

1 个答案:

答案 0 :(得分:0)

这是JSBin

只需在CSS中添加以下代码

即可
p{
  float:left;
}