多列布局 && 响应式布局

一:多列布局,应用  瀑布流

1:column-count

   属性规定元素应该被分隔的列数

2:column-gap

   属性规定列之间的间隔大小

3:column-rule

    设置或检索对象的列与列之间的边框。复合属性。

<style>
        div{
            height: 300px;
            background-color: yellowgreen;

            /*  控制显示的列数 */
            column-count: 3;

            /*  列与列之间的间距 */
            column-gap: 50px;

            /*  列的边框  */
            column-rule: 2px solid red;

            /*  控制列 高度统一属性  */
            column-fill: balance; 

            /*  设置为auto,则会先将父盒子高度占满,再换列  */

            /*  调整列宽   */
            /* column-width: 300px; 
               应用较少*/

        }

        div>h1 {
            /*  跨列属性   加给盒子里的项目  */
            column-span: all;
            text-align: center; /*  居中 */
        }
    </style>

补充知识点:

        1:break-inside:avoid; 不允许盒子内部进行折行。

二:响应式布局

几个设计显示原则:

 关键点:

 关键字:and,not(排除),only(仅限)

三:横竖屏的检测

横屏检测:orientation:landscape

竖屏检测:orientation:portrait

四:响应式布局案例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        .top{
            display: flex;  /* 弹性盒 */
            flex-wrap: wrap;  /* 折行  */
            justify-content: space-between; /* 两端对齐  */
        }

        .top>div {
            width: 49%;
        }

        .top img{
            width: 100%;
        }
        
        .right{
            display: flex;
            justify-content: space-between;
        }

        .right>div{
            width: 49%;
        }

        @media screen and  (max-width:6000px) {
            .top>div{
                width: 100%;
            }
            
        }

        .bottom{
            display: flex;
            flex-wrap: wrap;
            justify-content: space-around;
        }

        .bottom>div{
            width: 23%;
            padding: 5px;
            box-sizing: border-box;
            border: 1px solid gray;

            margin-bottom: 10px;
            box-shadow: 0 0 5px black;
        }

        .bottom img{
            width: 100%;
        }

        /* .bottom p{
            font-size: 200px;
        } */

        @media screen and (max-width:6000px) and (min-width:4500px) {
            .bottom>div{
                width: 31%;
            };
        }

        @media screen and (max-width:4500px) and (min-width:3000px) {
            .bottom>div{
                width: 48%;
            };
        }
        @media screen and (max-width:3000px) {
            .bottom>div{
                width: 100%;
            };
        }

    </style>
</head>
<body>
    <!-- 
        top部分,6000px为分界点
        >6000px: 左与右 各占一半,占一行  49%  剩余的1%分间隙
        <6000x:左边 100%,右边100%,折行
        选择弹性盒设计
     -->
     <div class="top">
        <div class="left">
            <img src="/photo/pic1.png" alt="">
        </div>

        <div class="right">
            <div class="p1">
                <img src="/photo/pic2.png" alt="">
            </div>
            <div class="p2">
                <img src="/photo/pic3.png" alt="">
            </div>
        </div>
      </div>

     <!-- 
        >6000:一行4个  各25%
        6000-4500  一行3个  33.33%
        4500-3000   一行2个   50%
        <3000     一行1个   100%
      -->

      <div class="bottom">
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
        <div>
            <img src="/photo/pic4.png" alt="">
            <p>微摄影展</p>
        </div>
      </div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值