博主信息
博文 22
粉丝 0
评论 0
访问量 19609
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
演示flex container 容器中的4个属性
杰西卡妈妈
原创
737人浏览过

1.实列flex项目上的三个属性

  • flex-grow 项目允许放大
  • flex-shrink 收缩
  • flex-basis 设置项目在主轴上的大小,它优先于项目本身的设置
    1. flex-grow: 1;
    2. flex-shrink: 0;
    3. flex-basis: auto;
    或者
    1. flex: 1 0 auto;
    还可以默认
    1. flex: initial;

代码区

效果:

  • flex-shrink 收缩
  • flex-basis 设置项目在主轴上的大小,它优先于项目本身的设置
  • order
    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>项目上的flex属性</title>
    <style>
    1. * {
    2. box-sizing: border-box;
    3. }
    4. :root {
    5. font-size: 10px;
    6. }
    7. body {
    8. font-size: 1.6rem;
    9. }
    10. .container {
    11. display: flex;
    12. height: 20rem;
    13. border: 1px solid #000;
    14. }
    15. .container > .item {
    16. width: 10rem;
    17. background-color: lightcyan;
    18. border: 1px solid #000;
    19. order: 0;
    20. }
    21. .item.one {
    22. background-color: #fff;
    23. order: 90;
    24. }
    25. .item.two {
    26. background-color: #ff7;
    27. }
    28. item.three {
    29. background-color: #9f7;
    30. }
    31. .item.four {
    32. background-color: #897;
    33. }
    </style>
    </head>
    <body>
    <div class="container">
    1. <div class="item one">item1</div>
    2. <div class="item two">item2</div>
    3. <div class="item three three">item3</div>
    4. <div class="item four">item4</div>
    </div>
    </body>
    </html>

2.移动商城首页的页眉和页脚的布局

  • 先写index.html, 写上3个div class: header,main and footer, 链接index.css, reset.css
  • 在css里面布局,保险一点最好在header and footer后面加上z-index.

    代码html

    <link rel="stylesheet" href="static/css/index.css" <div class="header">header</div>
    <div class="main">main</div>
    <div class="footer">footer</div>

    代码index.css

    @import “reset.css”
    .header {
    background: red
    color: white
    height: 4.4rem
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    z-index.100
    }
    .main {
    position: absolute;
    top: 4.4rem,
    left: 0;
    right: 0;
    bottom: 4.4rem;
    }
    .footer {
    background: grey;
    color: white;
    height: 4.4rem;
    position: fixed;
    left, bottom and right all are 0;
    z-size.100
    }

    代码reset.css

  • {
    margin: 0;
    padding:0;
    box-sizing: border-box;
    }
    li {
    list-style: none;
    }
    a {
    text-decoration: none;
    color: grey;
    }
    body {
    background-color: #f6f6f6;
    }
    html {
    font-size: 10px;
    }
    body {
    font-size: 1.6rem;
    }
    @media screen and (min-width: 480px) {
    html {
    font-size: 12px;
    }
    }

@media screen and (min-width: 640pz) {
html {
font-size: 14px;
}
}

@media screen and (min-width: 720pz) {
html {
font-size: 16px;
}
}

效果

本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学