English 中文(简体)
段、清单、插图
原标题:Paragraphs, lists, blockquotes with floating image
  • 时间:2012-04-18 06:24:51
  •  标签:
  • html
  • css

我有一个简单的例子:

<html>
<head>
    <style type="text/css">
        img {
            float: left;
            padding-left: 50px;
        }
        blockquote {
            background-color: #FF0;
        } 
    </style>
</head>
<body>
    <div>
        <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/84/HTML.svg/200px-HTML.svg.png" />
        <p>
            paragraph
        </p>
        <ul>
            <li>one</li>
            <li>two</li>
            <li>three</li>
        </ul>
        <ol>
            <li>one</li>
            <li>two</li>
            <li>three</li>
        </ol>
        <blockquote>
            <p>
                blockquoted paragraph 
            </p>
        </blockquote>
    </div>
</body>
</html>

因此,上页是:

“带有图像的网页”</p

同一页没有图像:

“没有图像的网页”</p

我必须结合文字调整,从第二个例子和向左边的图像(接线标示为红色):

“一个理想的页面”/

最佳回答

你们可以使用显示器:一线照相。

<div>
        <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/84/HTML.svg/200px-HTML.svg.png" />

     <div style="display:inline-block;">
     <p>
            paragraph
        </p>
        <ul>
            <li>one</li>
            <li>two</li>
            <li>three</li>
        </ul>
        <ol>
            <li>one</li>
            <li>two</li>
            <li>three</li>
        </ol>
        <blockquote>
            <p>
                blockquoted paragraph 
            </p>


        </blockquote>
</div>    
</div>​
问题回答

Add left floated div to both image and other section.

<html><head>
<style type="text/css">
    img {
        float: left;
        padding-left: 50px;
    }
    blockquote {
        background-color: #FF0;
    } 
div {
float: left;
}
</style>
</head>
<body>
<div>
    <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/84/HTML.svg/200px-HTML.svg.png"></div><div>
    <p>
        paragraph
    </p>
    <ul>
        <li>one</li>
        <li>two</li>
        <li>three</li>
    </ul>
    <ol>
        <li>one</li>
        <li>two</li>
        <li>three</li>
    </ol>
    <blockquote>
        <p>
            blockquoted paragraph 
        </p>
    </blockquote>
</div>

</body></html>

添加新的<代码>DIV,float:left。 See demo here on JSFiddle

I would just add margin-right: 50px; to the img style...





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签