前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >响应式

响应式

作者头像
4O4
发布2022-04-25 16:33:42
1.3K0
发布2022-04-25 16:33:42
举报
文章被收录于专栏:404404

响应式

代码语言:javascript
复制
<script>
  function init() {
    var width = document.documentElement.clientWidth
    document.documentElement.style.fontSize = width / 10 + 'px'
  }

  init()
  window.addEventListener('orientationchange', init)
  window.addEventListener('resize', init)
</script>

css媒体查询

代码语言:javascript
复制
 <style>
        .parent {
            width: 100%;
            height: 600px;
        }

        .child {
            float: left;
            height: 100px;
        }

        @media screen and (max-width: 960px) {
            .child {
                width: 33.3%;
            }

            .child-1 {
                background-color: red;
            }

            .child-2 {
                background-color: green;
            }

            .child-3 {
                background-color: blue;
            }
        }

        @media screen and (max-width: 768px) {
            .child {
                width: 50%;
            }

            .child-1 {
                background-color: red;
            }

            .child-2 {
                background-color: green;
            }

            .child-3 {
                background-color: blue;
            }
        }

        @media screen and (max-width: 550px) {
            .child {
                width: 100%;
            }

            .child-1 {
                background-color: red;
            }

            .child-2 {
                background-color: green;
            }

            .child-3 {
                background-color: blue;
            }
        }
    </style>

    <style media="(min-width: 960px) and (max-width: 1080px)">
        .child {
            width: 25%;
        }

        .child-1 {
            background-color: red;
        }

        .child-2 {
            background-color: green;
        }

        .child-3 {
            background-color: blue;
        }
    </style>

    <link href="./rwd.css" rel="stylesheet" media="(min-width: 1081px) and (max-width: 1920px)" />

flex弹性布局

代码语言:javascript
复制
// 存在剩余空间时设置间距的方式
justify-content: ;

rem

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-03-22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 响应式
    • css媒体查询
      • flex弹性布局
        • rem
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档