HTML_CSS学习:浮动

news2025/1/12 1:07:25

一、浮动简介

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浮动_简介</title>
    <style>
        div{
            width: 600px;
            height: 400px;
            background-color: #1c80d9;
        }
        img{
            float: right;
            /*margin-right: 0.5em;*/
        }
        .test::first-letter{
            font-size: 80px;
            float: left;
        }

    </style>
</head>
<body>
    <div>
        <img src="../pictures/喜羊羊.jpg" alt="" style="width: 200px;height: auto;">
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
        lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, quod.
    </div>
    <hr>
    <div class="test">
        The quick brown fox jumps over the lazy dog, while the eager beaver builds a sturdy dam and the proud peacock displays its vibrant plumage. A clever crow steals a shiny ring from the sleeping cat, as the noisy crowders chatter in the bustling city square. The brave knight slays the fearsome dragon with his trusty sword, and the joyful children play in the sunny meadow. The graceful swan glides on the serene lake, while the mischievous monkey swings from tree to tree. The diligent bee collects nectar from the colorful flowers, as the majestic eagle soars high in the clear blue sky. The talented artist captures the beauty of nature on her canvas, and the wise owl watches over the peaceful forest. The ambitious entrepreneur launches a successful startup, while the skillful chef prepares a delicious feast for the hungry guests. The curious kitten explores its new surroundings, as the faithful dog guards its owner’s home.
    </div>

</body>
</html>

显示结果:

二、元素浮动后的特点

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素浮动后的特点</title>
    <style>
        .outer{
            width: 800px;
            height: 400px;
            padding: 10px;
            background-color: #5dcd2d;
            text-align: center;
        }
        .box{
            font-size: 20px;
            padding: 10px;
        }
        .box1{
            background-color: red;
        }
        .box2{
            background-color: blue;
            float: left;
            /*width: 200px;*/
            /*height: 200px;*/
        }
        .box3{
            background-color: yellow;
            float: left;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class = "box box1">盒子1</div>
        <div class = "box box2">盒子2</div>
        <div class = "box box3">盒子3</div>

    </div>

</body>
</html>

显示结果:

三、浮动小练习

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浮动小练习</title>
    <style>
        .outer{
            width: 500px;
            background-color: #47c447;
            border: 1px solid black;
        }
        .box{
            width: 200px;
            height: 200px;
            background-color: red;
            border: 1px solid black;
            margin: 10px;
            float: left;
        }
        .box1{
            height: 230px;
        }
        /*.box1{*/
        /*    float: left;*/
        /*}*/
    </style>
</head>
<body>
    <div class="outer">
        <div class = "box box1">1</div>
        <div class = "box box2">2</div>
        <div class = "box box3">3</div>
    </div>
    <div style="background-color: #999ff0">The quick brown fox jumps over the lazy dog, while the eager beaver builds a sturdy dam and the proud peacock displays its vibrant plumage. A clever crow steals a shiny ring from the sleeping cat, as the noisy crowders chatter in the bustling city square. The brave knight slays the fearsome dragon with his trusty sword, and the joyful children play in the sunny meadow. </div>

</body>
</html>

显示结果:

四、浮动后的影响

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浮动后的影响</title>
    <style>
        .outer{
            width: 500px;
            background-color: #47c447;
            border: 1px solid black;
        }
        .box{
            width: 100px;
            height: 100px;
            background-color: red;
            border: 1px solid black;
            margin: 10px;
            /*float: left;*/
        }
        .box1,.box2,.box3{
            float: left;
        }

    </style>
</head>
<body>
    <div class="outer">
        <div class="box box0">0</div>
        <div class="box box1">1</div>
        <div class="box box2">2</div>
        <div class="box box3">3</div>
<!--        <div class="box box4">4</div>-->

    </div>
<!--    <div style="background-color: #999ff0">The quick brown fox jumps over the lazy dog, while the eager beaver builds a sturdy dam and the proud peacock displays its vibrant plumage. A clever crow steals a shiny ring from the sleeping cat, as the noisy crowders chatter in the bustling city square. The brave knight slays the fearsome dragon with his trusty sword, and the joyful children play in the sunny meadow. The graceful swan glides on the serene lake, while the mischievous monkey swings from tree to tree. The diligent bee collects nectar from the colorful flowers, as the majestic eagle soars high in the clear blue sky. The talented artist captures the beauty of nature on her canvas, and the wise owl watches over the peaceful forest. The ambitious entrepreneur launches a successful startup, while the skillful chef prepares a delicious feast for the hungry guests. The curious kitten explores its new surroundings, as the faithful dog guards its owner’s home. The powerful ocean waves crash against the rocky shore, and the gentle breeze whispers through the leaves of the ancient trees. The adventurous traveler explores remote villages in search of hidden treasures, while the playful dolphin leaps through the waves of the vast ocean. </div>-->

</body>
</html>

显示结果:

五、解决浮动后的影响

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>解决浮动后的影响</title>
    <style>
        .outer{
            width: 500px;
            background-color: #47c447;
            border: 1px solid black;
            /*第一种解决方案*/
            /*height: 122px;*/
            /*第二种解决方案*/
            /*float: left;*/
            /*第三种解决方案*/
            /*overflow: scroll;*/
        }

        .box{
            width: 100px;
            height: 100px;
            background-color: red;
            border: 1px solid black;
            margin: 10px;
            /*float: left;*/
        }
        .box1,.box2,.box3,.box4{
            float: left;
        }
        /*.box4{*/
        /*    !*display: inline-block;*!*/
        /*    !*height: 260px;*!*/
        /*    !*clear: left;*!*/
        /*    display: inline;*/
        /*    clear: both;*/
        /*    !*消除左侧浮动兄弟带来的影响*!*/
        /*}*/
        .box5{
            clear:both;
        }
        .mofa{
            /*第四种*/
            clear: both;
        }
        .outer::after{
            content: '';
            display: block;
            clear: both;
        }

    </style>
</head>
<body>
    <div class="outer">
<!--        <div class="box box0">0</div>-->
        <div class="box box1">1</div>
        <div class="box box2">2</div>
        <div class="box box3">3</div>
        <div class="box box4">4</div>
        <div class="box box5">5</div>
<!--        <div class="box box5">5</div>-->
<!--        <div class="mofa"></div>-->

    </div>
    <div style="background-color: #999ff0">The quick brown fox jumps over the lazy dog, while the eager beaver builds a sturdy dam and the proud peacock displays its vibrant plumage. A clever crow steals a shiny ring from the sleeping cat, as the noisy crowders chatter in the bustling city square. The brave knight slays the fearsome dragon with his trusty sword, and the joyful children play in the sunny meadow. The graceful swan glides on the serene lake, while the mischievous monkey swings from tree to tree. The diligent bee collects nectar from the colorful flowers, as the majestic eagle soars high in the clear blue sky. The talented artist captures the beauty of nature on her canvas, and the wise owl watches over the peaceful forest. The ambitious entrepreneur launches a successful startup, while the skillful chef prepares a delicious feast for the hungry guests. The curious kitten explores its new surroundings, as the faithful dog guards its owner’s home. The powerful ocean waves crash against the rocky shore, and the gentle breeze whispers through the leaves of the ancient trees. The adventurous traveler explores remote villages in search of hidden treasures, while the playful dolphin leaps through the waves of the vast ocean. </div>

</body>
</html>

显示结果:

六、浮动布局小练习

相关代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>浮动布局小练习</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .leftfix{
            float: left;
        }
        .rightfix{
            float: right;
        }
        .clearfix::after{
            content: '';
            display: block;
            clear: both;
        }
        .container{
            width: 960px;
            margin: 0 auto;
            text-align: center;
        }
        .logo{
            width: 200px;

        }
        .banner1{
            width: 540px;
            /*margin-left: 20px;*/
            /*margin-right: 20px;*/
            margin: 0 10px;

        }
        .banner2{
            width: 200px;
        }
        .logo,.banner1,.banner2{
            height: 80px;
            line-height: 80px;
            background-color: #c9c9c9;

        }
        .meun{
            height: 30px;
            background-color: #c9c9c9;
            margin-top: 10px;

        }
        .item1,.item2{
            width: 368px;
            height: 198px;
            line-height: 198px;
            border: 1px solid #000;
            margin-right: 10px;
        }
        .content{
            margin-top: 10px;
        }
        .item3,.item4,.item5,.item6{
            width: 178px;
            height: 198px;
            line-height: 198px;
            border: 1px solid #000;
            margin-right: 10px;
        }
        .bottom{
            margin-top: 10px;
        }
        .item7,.item8,.item9{
            width: 198px;
            height: 128px;
            line-height: 128px;
            border: 1px solid #000;
        }
        .item8{
            margin: 10px 0;
        }
        .footer{
            height: 60px;
            background-color: #c9c9c9;
            line-height: 60px;
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
<!--        头部-->
        <div class="page-header clearfix">
            <div class="logo leftfix">logo</div>
            <div class="banner1 leftfix">banner1</div>
            <div class="banner2 leftfix">banner2</div>

        </div>
<!--        菜单-->
        <div class="meun">菜单</div>
<!--        内容区-->
        <div class="content clearfix">
            <div class="left leftfix">
<!--                上-->
               <div class="top clearfix">
                   <div class="item1 leftfix">栏目一</div>
                   <div class="item2 leftfix">栏目二</div>
               </div>
<!--                下-->
               <div class="bottom">
                   <div class="item3 leftfix">栏目三</div>
                   <div class="item4 leftfix">栏目四</div>
                   <div class="item5 leftfix">栏目五</div>
                   <div class="item6 leftfix">栏目六</div>

               </div>
            </div>
            <div class="right rightfix">
                <div class="item7">栏目七</div>
                <div class="item8">栏目八</div>
                <div class="item9">栏目九</div>
            </div>
        </div>
<!--        页脚-->
        <div class="footer">页脚</div>
    </div>

</body>
</html>

显示结果:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1641804.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java进阶【十三期】:【异常处理】 (抛出捕获异常、自定义异常处理)、处理异常的几种方式 【(File】文件路径操作、File文件处理的综合练习

文章目录 Java进阶【十三期】&#xff1a;异常处理一、异常基本介绍二、编译异常和运行异常三、总结 异常的作用异常的处理方式一、JVM默认的处理方式二、自己处理异常自己 处理的问题 三、总结 Throwable 成员方法抛出异常总结 异常练习自定义异常 FileFile 三个 构造方法File…

【SSM进阶学习系列丨分页篇】PageHelper 分页插件导入集成实践

文章目录 一、说明什么是分页PageHelper介绍 二、导入依赖三、集成Spring框架中四、编写Service五、编写Controller六、编写queryAllByPage页面展示数据 一、说明 什么是分页 ​ 针对分页&#xff0c;使用的是PageHelper分页插件&#xff0c;版本使用的是5.1.8 。 ​ 参考文档…

力扣hot100:543. 二叉树的直径/108. 将有序数组转换为二叉搜索树

一、543. 二叉树的直径 LeetCode&#xff1a;543. 二叉树的直径 二叉树的直径 二叉树的 直径 是指树中任意两个节点之间最长路径的 长度 。 遇到二叉树的问题很容易去直接用求解的目标去定义递归函数。但是仔细考虑&#xff0c;返回树的直径并不能向上传播。因此我们可以拆…

三维球体空间中光线反射模拟与三维点云提取matlab仿真

目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.本算法原理 5.完整程序 1.程序功能描述 三维球体空间中光线反射模拟与三维点云提取matlab仿真。设置一个三维的椭球模型&#xff0c;作为墙壁&#xff0c;然后根据光线的反射原理&#xff0c;设计三维空…

Linux内核--设备驱动(四)基础通信接口整理

目录 一、引言 二、I2C ------>2.1、虚拟总线 ------>2.2、I2C适配器序列号指定 ------>2.3、I2C驱动的注册 ------>2.4、I2C设备的创建及注册 ------>2.5、probe 三、I2S 四、DMA ------>4.1、MMU IOMMU 一、引言 本篇文章对于常见通讯接口的内…

华为OD机试 - 小扇和小船的数字游戏 - 二进制(Java 2024 C卷 200分)

华为OD机试 2024C卷题库疯狂收录中&#xff0c;刷题点这里 专栏导读 本专栏收录于《华为OD机试&#xff08;JAVA&#xff09;真题&#xff08;A卷B卷C卷&#xff09;》。 刷的越多&#xff0c;抽中的概率越大&#xff0c;每一题都有详细的答题思路、详细的代码注释、样例测试…

题目:方格取数[Easy]

问题描述&#xff1a; 解题思路&#xff1a; 可以使用动态规划&#xff0c;建立dp[i][j][x]&#xff0c;表示&#xff08;1&#xff0c;1&#xff09;到&#xff08;i&#xff0c;j&#xff09;且其积的余数为x的情况下的方案数。时间复杂度为(n^2) * k。 AC代码&#xff1a; …

零基础学习数据库SQL语句之查询表中数据的DQL语句

是用来查询数据库表的记录的语句 在SQL语句中占有90%以上 也是最为复杂的操作 最为繁琐的操作 DQL语句很重要很重要 初始化数据库和表 USE dduo;create table tb_emp(id int unsigned primary key auto_increment comment ID,username varchar(20) not null unique comment…

USB2.0和USB3.0识别方式

一. USB2.0识别方式 USB2.0向下兼容USB1.0和USB1.1&#xff0c;分为低速、全速和高速三种模式。 1. 全速和低速识别 根据规范&#xff0c;全速和低速通过设备端的上拉电阻进行区分。当设备插入HUB或上电时&#xff0c;有上拉电阻的那根数据线就会被拉高&#xff0c;HUB根据D…

StampedLock(戳记锁)源码解读与使用

&#x1f3f7;️个人主页&#xff1a;牵着猫散步的鼠鼠 &#x1f3f7;️系列专栏&#xff1a;Java源码解读-专栏 &#x1f3f7;️个人学习笔记&#xff0c;若有缺误&#xff0c;欢迎评论区指正 1. 前言 我们在上一篇写ReentrantReadWriteLock读写锁的末尾留了一个小坑&#…

【Anaconda 3 】Jupyter Notebook 的安装配置及使用

Jupyter Notebook 的安装配置及使用 一、引言 Jupyter Notebook 是一种交互式笔记本&#xff0c;它允许用户将代码、注释、方程式、可视化内容等整合到一个文档中&#xff0c;并支持多种编程语言&#xff0c;如 Python、R、Julia 等。它在数据科学、机器学习和教育领域中得到…

ResponseHttp

文章目录 HTTP响应详解使用抓包查看响应报文协议内容 Response对象Response继承体系Response设置响应数据功能介绍Response请求重定向概述实现方式重定向特点 请求重定向和请求转发比较路径问题Response响应字符数据步骤实现 Response响应字节数据步骤实现 HTTP响应详解 使用抓…

Pytorch分布式train——pytorch.distributed.launch V.S. torchrun

1. 较早的pytorch.distributed.launch python -m torch.distributed.launch --nproc_per_node4 --nnodes1 --node_rank0 train.py --args XXX 参数解析&#xff1a; nnodes&#xff1a;节点&#xff08;主机&#xff09;的数量&#xff0c;通常一个节点对应一个主机 node_rank…

K8S哲学 - 资源调度 HPA (horizontal pod autoScaler-sync-period)

kubectl exec&#xff1a; kubectl exec -it pod-name -c container-name -- /bin/sh kubectl run 最小2个node 最大5个

Qt QImageWriter类介绍

1.简介 QImageWriter 用于写入图像文件的类。它提供了将 QImage 对象保存到不同图像格式文件的功能&#xff0c;包括但不限于 PNG、JPEG、BMP 等。QImageWriter 可以将图像写入文件&#xff0c;也可以写入任何 QIODevice&#xff0c;如 QByteArray&#xff0c;这使得它非常灵活…

恶补《操作系统》5_1——王道学习笔记

5设备管理 5.1_1 I-O设备的概念和分类 1、什么是I-O设备 输入/输出&#xff1a;I/O设备就是可以将数据输入到计算机&#xff0c;或者可以接收计算机输出数据的外部设备&#xff0c;属于计算机中的硬件部件。 2、按使用特性分类 人机交互的外部设备存储设备网络通信设备 3、…

io流,字节流概述

io流概述 io流&#xff1a;输入输出流读写数据的 i 指Input&#xff0c;称为输入流:负责把数据读到内存中去 o指Output&#xff0c;称为输出流:负责写数据出去 io流的分类 按流的方向分为: 输入流和输出流。 按流中数据的最小单位&#xff0c; 分为:字节流&#xff08;适合操作…

LWIP+TCP客户端

一、TCP API函数 其中tcp_poll()函数的第三个参数表示隔几秒调用一次这个周期性函数 二、修改服务器的IP 三、TCP客户端编程思路 申请套接字绑定服务器IP和端口号等待客户端连接 进入连接回调函数在连接回调函数中 配置一些回调函数&#xff0c;如接收回调函数&#xff0c;周期…

C++必修:类与对象(三)

✨✨ 欢迎大家来到贝蒂大讲堂✨✨ &#x1f388;&#x1f388;养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; 所属专栏&#xff1a;C学习 贝蒂的主页&#xff1a;Betty’s blog 1. 隐式类型转换 在学习C语言时我们就明白&#xff0c;当我们进行赋值时&#xf…

智慧旅游引领旅游行业创新发展:借助智能科技的力量,实现旅游资源的优化配置和高效利用,推动旅游行业的转型升级和可持续发展

目录 一、引言 二、智慧旅游的定义与特点 1、信息化程度高 2、智能化服务丰富 3、互动性强 4、个性化服务突出 5、可持续性发展 三、智慧旅游在旅游行业创新发展中的作用 &#xff08;一&#xff09;优化旅游资源配置 &#xff08;二&#xff09;提升旅游服务质量 &…