会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132376个问题
JAVA 全系列/第六阶段:项目管理与SSM框架/Spring旧 7831楼
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 7833楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS3新特性 7834楼

嗷嗷刚刚代码那个p标签写在div外面了,现在解决了,用两种方式清楚浮动都可以了

    <style>

        *{

            margin: 0;

            padding: 0;

        }

        .nav{

            width: 100%;

            height: 68px;

            background-color: rgba(0,0,0,.85);

        }

        .nav ul {

            list-style: none;

            margin-left: 300px;

            line-height: 68px;

            /* overflow: hidden; */

        }


        .nav ul::after{

            content: "";

            overflow: hidden;

            clear: both;

        }


        .nav ul li{

            float: left;

            padding: 0 20px;

        }


        .nav ul li a{

            text-decoration: none;

            color: white;


        }


        .nav ul li a:hover{

            color: #ff6700;

        }


        p{

            clear: both;

        }


    </style>

</head>

<body>

    <div class="nav">

        <ul>

            <li>

                <a href="#">小米商城</a>

            </li>

            <li>

                <a href="#">小米影像</a>

            </li>

            <li>

                <a href="#">MIUI</a>

            </li>

            <li>

                <a href="#">LOT</a>

            </li>

            <li>

                <a href="#">云服务</a>

            </li>

            <li>

                <a href="#">天星科技</a>

            </li>

            <li>

                <a href="#">有品</a>

            </li>

            <li>

                <a href="#">小爱开放平台</a>

            </li>

            <li>

                <a href="#">企业团购</a>

            </li>

        </ul>

        <p>testtest</p>

    </div>


</body>


WEB前端全系列/第一阶段:HTML5+CSS3模块/浮动与定位 7835楼

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=, initial-scale=1.0">

    <title>Document</title>

    <style>

        *{

            margin: 0;

            padding: 0;

        }

        .nav{

            width: 100%;

            height: 68px;

            background-color: rgba(0,0,0,.85);

        }

        .nav ul {

            margin-left: 300px;

        }


        .nav ul li{

            float: left;

            padding: 0 20px;

            display: inline;

        }


        .nav ul li a{

            text-decoration: none;

            color: white;

            line-height: 68px;

        }


        .nav ul li a:hover{

            color: #ff6700;

        }


    </style>

</head>

<body>

    <div class="nav">

        <ul>

            <li>

                <a href="#">小米商城</a>

            </li>

            <li>

                <a href="#">小米影像</a>

            </li>

            <li>

                <a href="#">MIUI</a>

            </li>

            <li>

                <a href="#">LOT</a>

            </li>

            <li>

                <a href="#">云服务</a>

            </li>

            <li>

                <a href="#">天星科技</a>

            </li>

            <li>

                <a href="#">有品</a>

            </li>

            <li>

                <a href="#">小爱开放平台</a>

            </li>

            <li>

                <a href="#">企业团购</a>

            </li>

        </ul>

    </div>

    <p>testtest</p>

</body>

</html>

老师为啥这个结果不用清除浮动,也可以p标签在下面?

image.png

WEB前端全系列/第一阶段:HTML5+CSS3模块/浮动与定位 7836楼
人工智能/第二十四阶段:百度飞桨PaddlePaddle实战/PaddleDetection工具_PCB电路板缺陷检测 7837楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 7838楼

maven_demo2.zip

微信截图_20221022211913.png老师,我的这个显示模块也没问题了,不知道为什么跑不了

JAVA 全系列/第六阶段:项目管理与SSM框架/Maven 7839楼
JAVA 全系列/(隐藏)第二十三阶段:数字货币交易所项目/服务中台_交易系统的开发 7840楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 7841楼
Python 全系列/第二阶段:Python 深入与提高/(旧)坦克大战 7842楼
WEB前端全系列/第一阶段:HTML5+CSS3模块/浮动与定位 7843楼

   <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-color: aliceblue;
        }

        .container {
            width: 1080px;
            margin: 0 auto;
        }

        .container ul {
            overflow: hidden;
            clear: both;
        }

        .container ul li {
            position: relative;
            float: left;
            list-style: none;
            background-color: #fff;
            margin: 10px 9px 0 0;
            width: 260px;
            height: 375px;
        }

        .container ul li:nth-child(4n) {
            margin-right: 0;
        }

        .container ul li a {
            display: block;
            width: 100%;
            height: 100%;
            text-align: center;
            text-decoration: none;
            padding-top: 20px;
        }

        img {
            width: 250px;
            height: 230px;

        }

        .container ul li a .text {
            width: 100%;
            margin-top: 20px;
        }

        .text .name {
            display: block;
            color: #333;
            font-size: 16px;
            margin-bottom: 3px;
        }

        .text .desc {
            display: block;
            color: #999;
            font-size: 15px;
        }

        .text .price i {
            font-style: normal;
            font-size: 17px;
            color: red;
        }

        .text .price {
            display: inline-block;
            color: red;
            font-size: 22px;
            /* padding-left: 14px; */
        }

        .text .price em {
            font-size: 16px;
            font-style: normal;
        }

        .prodect-sign {
            position: absolute;
            top: 15px;
            left: 20px;
            display: block;
            width: 55px;
            height: 55px;
            background-color: pink;
            border-radius: 60%;
            line-height: 55px;
            color: #fff;
            font-size: 16px;
        }
    </style>
</head>

<body>
    <div class="container">
        <ul>
            <li>
                <a href="#">
                    <img src="./img/1.webp" alt="">
                    <div class="text">
                        <span class="name">小米 11Pro</span>
                        <span class="desc">限时优惠,抢购吧</span>
                        <span class="price"><i>¥</i>1999<em>起</em></span>
                    </div>
                    <span class="prodect-sign">免息</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <img src="./img/2.png" alt="">
                    <div class="text">
                        <span class="name">小米 12Pro</span>
                        <span class="desc">限时优惠,抢购吧</span>
                        <span class="price"><i>¥</i>2999<em>起</em></span>
                    </div>
                    <span class="prodect-sign">免息</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <img src="./img/1.webp" alt="">
                    <div class="text">
                        <span class="name">小米 11U</span>
                        <span class="desc">限时优惠,抢购吧</span>
                        <span class="price"><i>¥</i>2222<em>起</em></span>
                    </div>
                    <span class="prodect-sign">免息</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <img src="./img/2.png" alt="">
                    <div class="text">
                        <span class="name">小米 12U</span>
                        <span class="desc">限时优惠,抢购吧</span>
                        <span class="price"><i>¥</i>3333<em>起</em></span>
                    </div>
                    <span class="prodect-sign">免息</span>
                </a>
            </li>
        </ul>
    </div>
</body>

偷懒用老师写的尺寸,但是看着好大啊,对于类名还是不会起名字,不会管理

image.png

WEB前端全系列/第一阶段:HTML5+CSS3模块/浮动与定位 7844楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637