美文网首页
flex 垂直居中demo

flex 垂直居中demo

作者: 追逐繁星的阿忠 | 来源:发表于2020-07-15 09:16 被阅读0次
image.png
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta charset="utf-8">
  <title>Title</title>
  <style>

      .animated {
          -webkit-animation-duration: 1s;
          animation-duration: 1s;
          -webkit-animation-fill-mode: both;
          animation-fill-mode: both;
      }

      .animated.infinite {
          -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
      }

      @keyframes myShadow {
          from{
              box-shadow: 0 0 25px 4px #f00;
          }
          to{
              box-shadow: 0 0 25px 4px #f00 inset;
          }
      }
      .myShadow {
          -webkit-animation-name: myShadow;
          animation-name: myShadow;
      }
      .Site {
          display: flex;
          min-height: 100vh;
          height: 100vh;
          flex-direction: column;
          background-color: rgba(86, 160, 177, 0.47);
      }

      .Site-content {
          display: flex;
          flex: 1;
          text-align: center;
          line-height: 100%;
          justify-content:center;
          /*先主轴上的对齐方式*/
          align-items:center;
          /*然后交叉轴上如何对齐
            (元素所在位置垂直于主轴方向的位置画垂直线即为交叉轴)
          */
      }

      .Site-content div{
          width: 200px;
          height: 200px;
          background-color: #a8a8b1;
          color: red;
          font-size: 18px;
          text-align: center;
          line-height: 200px;
          /*box-shadow: 0 0 10px #f00;*/
          /*box-shadow: 0 0 25px 4px #f00;*/
          /*box-shadow: 0 0 25px 4px #f00 inset;*/
      }

      footer,header{
          width: 100%;
          height: 100px;
          background-color: #2b2b2b;
      }
      header{
          background-color: #00AA88;
      }
  </style>
</head>
<body class="Site">
  <header>...</header>
  <main class="Site-content">
      <div class="animated infinite myShadow">此处编辑类容</div>
  </main>
  <footer>...</footer>
</body>
</html>
<!--小结用到的知识点:
1:flex只有一整屏时,固定底栏
2:flex的方式水平垂直居中一个元素  容器的flex属性:justify-content 和 align-items
3:box-shadow的使用  box-shadow: h-shadow:水平阴影位置 v-shadow:垂直阴影位置 [blur:模糊距离] [spread:阴影大小] [color:阴影颜色] [inset];
4:keyframes自定义动画
-->


岁月轮转,时光静静的流逝,金秋的风,悄悄地拂过窗棂,轻轻地掀起清秋的面纱,听风,唱响时间的流淌,穿过,岁月沧桑的河岸,仿佛,经年就在眼前,那些消失在岁月长河里的人和事,还有一些一些的美丽,都化着点滴斑斓,飞散在这个季节深处。岁月,就是一轮维修机,有再多磨合都已不在重要,重要的是有一颗宽容,淡定,从容的心。守着一份份清淡,[生活]已不再那么烦躁,或许,生活就是要我们简单随和,就是最好……
生活就是要我们简单随和,就是最好……

生活就是要我们简单随和,就是最好……

相关文章

网友评论

      本文标题:flex 垂直居中demo

      本文链接:https://www.haomeiwen.com/subject/httdhktx.html