Home Web Front-end HTML Tutorial Why float can realize text wrapping around pictures without overlapping

Why float can realize text wrapping around pictures without overlapping

Jun 07, 2017 am 09:54 AM

Today I read the chapter on graphic CSS. Although it mainly talks about the use of the nth-of-type selector, I paid attention to the layout of the page, as follows:

HTML

<body>
<p class="article">
<img src="http://img.ujian.cc/nice/35.jpg" alt="" />
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
<img src="http://img.ujian.cc/nice/36.jpg" alt="" />
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
<img src="http://img.ujian.cc/nice/38.jpg" alt="" />
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
        </p>
</body>
Copy after login

CSS

<style type="text/css">.article {width: 500px;margin: 20px auto;}.article img:nth-of-type(odd){float: left;margin-right: 10px;}.article img:nth-of-type(even){float: right;margin-left: 10px;}</style>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

HTML, CSS and jQuery: Make a button with a floating effect HTML, CSS and jQuery: Make a button with a floating effect Oct 24, 2023 pm 12:09 PM

HTML, CSS and jQuery: Make a button with a floating effect

Is there any way to clear floats? Is there any way to clear floats? Feb 22, 2024 pm 04:00 PM

Is there any way to clear floats?

HTML layout tips: How to use the position attribute for floating element control HTML layout tips: How to use the position attribute for floating element control Oct 21, 2023 am 09:22 AM

HTML layout tips: How to use the position attribute for floating element control

Guide to CSS image properties: outline and display Guide to CSS image properties: outline and display Oct 25, 2023 am 08:57 AM

Guide to CSS image properties: outline and display

CSS Floats and Clear Floats: Mastering Floats and Clear Floats CSS Floats and Clear Floats: Mastering Floats and Clear Floats Nov 18, 2023 am 10:56 AM

CSS Floats and Clear Floats: Mastering Floats and Clear Floats

Discuss the reasons why fixed positioning cannot be used in HTML Discuss the reasons why fixed positioning cannot be used in HTML Jan 20, 2024 am 10:15 AM

Discuss the reasons why fixed positioning cannot be used in HTML

CSS drop-down menu property optimization tips: position and z-index CSS drop-down menu property optimization tips: position and z-index Oct 20, 2023 pm 12:02 PM

CSS drop-down menu property optimization tips: position and z-index

Comprehensive list of CSS layout properties: display, position and float Comprehensive list of CSS layout properties: display, position and float Oct 20, 2023 pm 05:36 PM

Comprehensive list of CSS layout properties: display, position and float

See all articles