search
HomeWeb Front-endHTML TutorialWhy float can realize text wrapping around pictures without overlapping

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="/static/imghwm/default1.png"  data-src="http://img.ujian.cc/nice/35.jpg"  class="lazy"   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="/static/imghwm/default1.png"  data-src="http://img.ujian.cc/nice/36.jpg"  class="lazy"   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="/static/imghwm/default1.png"  data-src="http://img.ujian.cc/nice/38.jpg"  class="lazy"   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>

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>
Statement
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
HTML、CSS和jQuery:制作一个带有浮动效果的按钮HTML、CSS和jQuery:制作一个带有浮动效果的按钮Oct 24, 2023 pm 12:09 PM

HTML、CSS和jQuery:制作一个带有浮动效果的按钮,需要具体代码示例引言:如今,网页设计已成为一种艺术形式,通过使用HTML、CSS和JavaScript等技术,我们能够为页面增加各种各样的特效和交互效果。本文将简要介绍如何用HTML、CSS和jQuery制作一个带有浮动效果的按钮,并提供具体的代码示例。一、HTML结构首先,我们需要在HTML文件中

清除浮动有什么方法清除浮动有什么方法Feb 22, 2024 pm 04:00 PM

清除浮动有什么方法,需要具体代码示例在网页布局中,浮动是一种常用的布局方法,可以让元素脱离文档流,并相对其他元素进行定位。然而,使用浮动布局时常常会遇到一个问题,就是父元素无法正确地包裹浮动元素,导致页面产生布局错乱的情况。所以,我们需要采取措施来清除浮动,使得父元素能够正确地包裹浮动元素。清除浮动的方法有多种,下面将介绍常用的几种方法,并给出具体的代码示例

HTML布局技巧:如何使用position属性进行浮动元素控制HTML布局技巧:如何使用position属性进行浮动元素控制Oct 21, 2023 am 09:22 AM

HTML布局技巧:如何使用position属性进行浮动元素控制在网页设计中,布局是非常重要的一环。通过合理的布局可以使网页更加美观、易读,提升用户体验。而在实现布局过程中,浮动元素的控制是其中一个关键点。HTML提供了position属性,通过这个属性我们可以实现对浮动元素的控制。本文将介绍如何使用position属性进行浮动元素的布局,并提供一些具体的代码

CSS 图像属性指南:outline 和 displayCSS 图像属性指南:outline 和 displayOct 25, 2023 am 08:57 AM

CSS图像属性指南:outline和displayCSS是前端开发中不可或缺的一部分,其中图像属性也是必不可少的。在这篇文章中,我们将重点介绍两个关于图像属性的重要概念:outline和display。本文将详细说明它们的定义、用法以及具体的代码示例。outline属性概述:outline属性用于在元素周围创建一个轮廓线,不占据布局空间。它是

CSS浮动和清除浮动:掌握浮动和清除浮动的技巧CSS浮动和清除浮动:掌握浮动和清除浮动的技巧Nov 18, 2023 am 10:56 AM

CSS浮动和清除浮动:掌握浮动和清除浮动的技巧,需要具体代码示例在网页设计和开发中,CSS浮动(float)是常见的布局技术之一。使用浮动可以将元素向左或者向右移动,从而实现元素在页面中的位置调整和排列。然而,浮动元素也会给页面造成一些问题,比如父元素高度塌陷等。因此,掌握浮动的使用和清除浮动的技巧非常重要。本文将重点介绍CSS浮动和清除浮动的技巧,并提供具

CSS 布局属性大全:display,position 和 floatCSS 布局属性大全:display,position 和 floatOct 20, 2023 pm 05:36 PM

CSS布局属性大全:display,position和floatCSS是用于控制网页样式的一种标记语言。在设计网页布局时,布局属性是非常重要的。CSS提供了多种布局属性,其中最常用的是display,position和float。在本篇文章中,我们将详细介绍这三种布局属性,并提供具体代码示例。display属性display属性用于指定元

探讨HTML中固定定位无法使用的原因探讨HTML中固定定位无法使用的原因Jan 20, 2024 am 10:15 AM

HTML中无法使用固定定位的问题探讨随着互联网的快速发展,网页设计也变得越来越复杂多样化。在网页设计中,经常需要使用固定定位(position:fixed)来控制元素的位置,使得页面可以实现一些特殊的效果。然而,在一些情况下,HTML中却无法使用固定定位,导致设计师们头疼不已。本文将探讨在HTML中无法使用固定定位的问题,并提供具体的代码示例。一、浮动元素

CSS 下拉菜单属性优化技巧:position 和 z-indexCSS 下拉菜单属性优化技巧:position 和 z-indexOct 20, 2023 pm 12:02 PM

CSS下拉菜单属性优化技巧:position和z-index在网页设计中,下拉菜单是常见的交互元素之一。通过下拉菜单,用户可以方便地选择所需的选项,提升用户体验。然而,当页面中存在多个下拉菜单时,它们的位置和层叠关系可能会产生问题。为了解决这些问题,我们可以通过使用CSS中的position属性和z-index属性来优化下拉菜单的展示效果。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.