点击a标签弹出弹窗(点击a标签弹出div)

点击a标签弹出弹窗(点击a标签弹出div)style one width 100px height 100px background color red float left two width 200px height 200px background color blue float right style lt

大家好,我是讯享网,很高兴认识大家。




讯享网

<style>

        .one{

            width: 100px;

            height: 100px;

            background-color: red;

            float: left;

        }

        .two{

            width: 200px;

            height: 200px;

            background-color: blue;

            float: right;

        }

    </style>

</head>

<body>

    <div class="one">爱</div>

    <div class="two">keadasf</div>

</body>

如果两个都是left,则效果为:

!!!如果只给一个div加float属性的话,会导致两个盒子重叠!!!

例如将.two中的float属性去掉,事实上只有.one才被系统承认

顶对齐

具备行内块特点

脱离标准流

父级宽度不够,子级会浮动换行

产品区域布局

4.1.效果

4.2代码

<style>

        *{

            margin: 0;

            padding: 0;

        }

        li{

            list-style: none;

        }

        .product{

            margin: 50px auto;

            width: 1229px;

            height: 628px;

            background-color: pink;

        }

        .left{

            width: 234px;

            height: 628px;

            background-color: red;

            float: left;

        }

        .right{

            width: 978px;

            height: 628px;

            background-color: blue;

            float: left;

        }

        .right li{

            margin-bottom: 14px;

            margin-right: 14px;

            width: 234px;

            height: 300px;

            background-color: orange;

            float: left;

        }

        .right li:nth-child(4n){

            margin-right: 0;

        }

    </style>

</head>

<body>

    <div class="product">

        <div class="left"></div>

        <div class="right">

            <ul>

                <li></li>

                <li></li>

                <li></li>

                <li></li>

                <li></li>

                <li></li>

                <li></li>

                <li></li>

            </ul>

        </div>

    </div>

</body>

</html>

4.3总结

(1)父级宽度不够,浮动的盒子会掉下来

(2)可以利用无序列表的:nth-child()取消部分盒子的内外边框

(3)版心居中 margin:上下 auto   (左右设置为auto即可)

<style>

        *{

            margin: 0;

            padding: 0;

        }

        .product{

            margin: 20px auto;

            width: 900px;

            height: 600px;

            background-color: pink;

        }

        .left{

            width: 200px;

            height: 600px;

            background-color: red;

            float: right;

        }

        .right{

            width: 700px;

            height: 600px;

            background-color: blue;

            float: left;

        }

        .box{

            height: 100px;

            background-color: black;

        }

    </style>

</head>

<body>

    <div class="product">

        <div class="left"></div>

        <div class="right"></div>

    </div>

    <div class="box"></div>

正常情况

当父级product没设置高度时:

product高度化为0,底下的box直接上移,影响布局

2.1额外标签法

在父元素内容的最后添加一个块元素,并设置CSS属性   clear:both   (其中除了both还有left,right指去除xx方向的浮动影响)

 .clearfex{

            clear: both;

        }

   ……..

    &lt;div class=“product”&gt;

        &lt;div class=“left”&gt;&lt;/div&gt;

        &lt;div class=“right”&gt;&lt;/div&gt;

        &lt;div class=“clearfex”&gt;&lt;/div&gt;

    &lt;/div&gt;

    &lt;div class=“box”&gt;&lt;/div&gt;

2.2单伪元素法

.clearfex::after{

            content: “”;                            /伪元素法必须要有content属性,否则无法生效/

            display: block;

            clear: both;

        }

   ……….

&lt;div class=“product clearfex”&gt;                     /top要调用clearfex/

        &lt;div class=“left”&gt;&lt;/div&gt;

        &lt;div class=“right”&gt;&lt;/div&gt;

    &lt;/div&gt;

    &lt;div class=“box”&gt;&lt;/div&gt;

2.3双伪元素法(推荐)

/其中before是为了解决外边距塌陷问题,子级设置的外边距可能会将父级下拉)/

.clearfex::before,

        .clearfex::after{

            content: “”;

            display: table;

        }

        .clearfex::after{

            clear: both;

        }

…………

&lt;div class=“product clearfex”&gt;

        &lt;div class=“left”&gt;&lt;/div&gt;

        &lt;div class=“right”&gt;&lt;/div&gt;

    &lt;/div&gt;

    &lt;div class=“box”&gt;&lt;/div&gt;

2.4 overflow属性

剪掉超出父级的选项

overflow:hidden

2.5效果

自动撑开高度,高度为子级中最大的高度。

.box{

            /* 将盒子变为弹性布局 */

            display: flex;

            justify-content: space-between;

            /* 如果去掉height,高度根据内容浮动,不会脱标 */

            height: 300px;

            border: 1px solid black;

        }

关于拉伸和挤压:如果子级设置了宽高,由于较多子级,则自动挤压子级的原有宽度。如果子级没有设置高度,则自动将子级拉伸为与父级盒子同高。

常用后四个属性值

!!!注意:一个是全部,一个是单独处理

!!!stretch必须不设置弹性盒子的高度才能实现拉伸

!!!控制单个盒子使用伪类选择器:

.box div:nth-child(2){

            align-self: center;

        }

!!!重点记住column,如果主轴方向变化,则侧轴也会跟着变主侧两轴始终垂直

.box div:nth-child(2){

            flex: 1;

        }

弹性盒子2占父级除13外的尺寸一大份。

.box div:nth-child(2){

            flex: 1;

        }

        .box div:nth-child(3){

            flex: 3;

        }

除去盒子1,弹性盒子23分别占剩余父级尺寸的1/4和3/4。

!!!和主轴对齐的属性值相同

!!!弹性行对齐对单行弹性盒子不生效,所以记得换行flex-wrap

抖音解决方案

大体思路为:

1.清除格式

2.大盒子嵌套四个小盒子,四个小盒子可使用无序列表(无序列表属于行标签,记得转换为弹性盒子)

3.设置大盒子:盒子大小,盒子版心位置,边框线,是否圆角等性质。

4.无序列表转弹性盒子,调整各盒子在主轴对齐方式,换行,行对齐方式,内外边距等性质。

5.四个小盒子设置宽高,里面分两个小盒子,一个图片一个文本,转为弹性两个小盒子。

6.设置两个弹性小盒子在主侧轴的分布方式,盒子背景颜色等。

7.单独设置两盒子里面的图片格式和文字大小等性质。

&lt;title&gt;抖音解决方案&lt;/title&gt;

    &lt;style&gt;

        *{

            margin: 0;

            padding: 0;

            box-sizing: border-box;

        }

        li{

            list-style: none;

        }

        /以上为清除格式/

        .box{

            margin: 200px auto;

            border-radius:20px;

            width: 800px;

            height: 400px;

            border: 2px solid black;

        }

        .box ul{

            display: flex;

            justify-content: space-between;  /调整主轴方向对齐方式/

            flex-wrap: wrap;  /弹性盒子换行/

            align-content: space-around;      /行对齐/

            padding: 30px 20px 30px 20px;

            height: 400px;

        }

        .box li{

            width: 360px;

            height: 150px;

            display: flex;

            justify-content: center;

            align-items: center;

            background-color: white;

        }

        .box .pic1{

            margin-right: 15px;

        }

        .box .text1 h4{

            font-size: 18px;

            line-height: 30px;

        }

        .box .text1 p{

            font-size: 15px;

            color: #666;

        }

       

    &lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;

    &lt;div class=“box”&gt;

        &lt;ul&gt;

            &lt;li&gt;

                &lt;div class=“pic1”&gt;

                    &lt;img src=“http://www.mzph.cn/diannao/抖音解决方案1.png" alt=”“&gt;

                &lt;/div&gt;

                &lt;div class=”text1“&gt;

                    &lt;h4&gt;一键发布多域&lt;/h4&gt;

                    &lt;p&gt;发布头条i需要官网确认,比如新闻&lt;/p&gt;

                &lt;/div&gt;

            &lt;/li&gt;

            &lt;li&gt;

                &lt;div class=”pic1“&gt;

                   &lt;img src=”http://www.mzph.cn/diannao/抖音解决方案2.png" alt=“”&gt;

                &lt;/div&gt;

                &lt;div class=“text1”&gt;

                   &lt;h4&gt;一键发布多域&lt;/h4&gt;

                   &lt;p&gt;发布头条i需要官网确认,比如新闻&lt;/p&gt;

                &lt;/div&gt;

            &lt;/li&gt;

            &lt;li&gt;

                &lt;div class=“pic1”&gt;

                   &lt;img src=“http://www.mzph.cn/diannao/抖音解决方案3.png" alt=”“&gt;

                &lt;/div&gt;

                &lt;div class=”text1“&gt;

                    &lt;h4&gt;一键发布多域&lt;/h4&gt;

                    &lt;p&gt;发布头条i需要官网确认,比如新闻&lt;/p&gt;

                &lt;/div&gt;

            &lt;/li&gt;

            &lt;li&gt;

                &lt;div class=”pic1“&gt;

                    &lt;img src=”http://www.mzph.cn/diannao/抖音解决方案4.png" alt=“”&gt;

                &lt;/div&gt;

                &lt;div class=“text1”&gt;

                    &lt;h4&gt;一键发布多域&lt;/h4&gt;

                    &lt;p&gt;发布头条i需要官网确认,比如新闻&lt;/p&gt;

                &lt;/div&gt;

            &lt;/li&gt;

        &lt;/ul&gt;

    &lt;/div&gt;

&lt;/body&gt;

小讯
上一篇 2025-05-03 18:36
下一篇 2025-06-13 20:06

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/177159.html