欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

媒体查询,固定定位,flex属性

程序员文章站 2022-03-01 18:33:03
...

媒体查询

PC优先

  1. @media screen and (min-width: 750px) {
  2. html {
  3. font-size: 16px;
  4. }
  5. }
  6. @media screen and (min-width: 375px) and (max-width: 749px) {
  7. html {
  8. font-size: 14px;
  9. }
  10. }
  11. @media screen and (max-width: 374px) {
  12. html {
  13. font-size: 12px;
  14. }
  15. }

固定定位

登录页面

  1. <form action="" class="modal-form">
  2. <fieldset>
  3. <legend>用户登录</legend>
  4. <input type="email" name="emil" placeholder="username@email.com" />
  5. <input type="password" name="password" placeholder="******" />
  6. <button>登录</button>
  7. </fieldset>
  8. </form>

固定位置

  1. .modal .modal-form {
  2. position: fixed;
  3. top: 10em;
  4. left: 20em;
  5. right: 20em;
  6. }

flex 属性

1.flex-flow:主轴方向,不换行/换行

  1. flex-flow: row nowrap;
  2. flex-flow: row wrap;

2.place-content:项目在主轴上的排列与空间分配

  1. place-content: start;
  2. place-content: end;
  3. place-content: center;
  4. place-content: space-between;
  5. place-content: space-around;
  6. place-content: space-evenly;

3.place-item:项目在交叉轴上的对齐方式

  1. place-items: stretch;
  2. place-items: start;
  3. place-items: end;
  4. place-items: center;

4.flex:放大因子 收缩因子 计算宽度

  1. flex:auto;
  2. flex:1 1 auto;
  3. flex:0 1 auto;
  4. flex:0 0 auto;

5.order越小越靠前