美文网首页
宇宙通用的CSS工具类整理

宇宙通用的CSS工具类整理

作者: microkof | 来源:发表于2019-06-25 18:18 被阅读0次

    前言

    这里我整理一份我自用的工具类,我的用法并不是把所有的类存成一个css文件,而是项目中用到哪个,就拷贝哪个。

    这些类的特点:不依赖于任何框架,也不需要任何说明文档。

    常用

    ::-webkit-scrollbar {
      display: none;
    }
    
    .hidden {
      display: none;
    }
    
    .w-100 {
      width: 100%;
    }
    
    .h-100 {
      height: 100%;
    }
    
    .vw-100 {
        width: 100vw;
    }
    
    .vh-100 {
        height: 100vh;
    }
    

    浮动

    .fl {
      float: left;
    }
    
    .fr {
      float: right;
    }
    
    .cb::after {
      clear: both;
    }
    

    position

    
    .static {
      position: static;
    }
    
    .relative {
      position: absolute;
    }
    
    .absolute {
      position: absolute;
    }
    
    .fixed {
      position: fixed;
    }
    
    .position-0 {
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
    }
    
    .top-0 {
      top: 0;
    }
    
    .bottom-0 {
      bottom: 0;
    }
    
    .left-0 {
      left: 0;
    }
    
    .right-0 {
      right: 0;
    }
    

    flex弹性布局

    .flex {
      display: flex;
    }
    
    .basis-xs {
      flex-basis: 20%;
    }
    
    .basis-sm {
      flex-basis: 40%;
    }
    
    .basis-df {
      flex-basis: 50%;
    }
    
    .basis-lg {
      flex-basis: 60%;
    }
    
    .basis-xl {
      flex-basis: 80%;
    }
    
    .flex-sub {
      flex: 1;
    }
    
    .flex-twice {
      flex: 2;
    }
    
    .flex-treble {
      flex: 3;
    }
    
    .flex-direction {
      flex-direction: column;
    }
    
    .flex-wrap {
      flex-wrap: wrap;
    }
    
    .align-start {
      align-items: flex-start;
    }
    
    .align-end {
      align-items: flex-end;
    }
    
    .align-center {
      align-items: center;
    }
    
    .align-stretch {
      align-items: stretch;
    }
    
    .self-start {
      align-self: flex-start;
    }
    
    .self-center {
      align-self: flex-center;
    }
    
    .self-end {
      align-self: flex-end;
    }
    
    .self-stretch {
      align-self: stretch;
    }
    
    .align-stretch {
      align-items: stretch;
    }
    
    .justify-start {
      justify-content: flex-start;
    }
    
    .justify-end {
      justify-content: flex-end;
    }
    
    .justify-center {
      justify-content: center;
    }
    
    .justify-between {
      justify-content: space-between;
    }
    
    .justify-around {
      justify-content: space-around;
    }
    

    内外间距

    .margin-0 {
      margin: 0;
    }
    
    .margin-xs {
      margin: 5px;
    }
    
    .margin-sm {
      margin: 10px;
    }
    
    .margin {
      margin: 15px;
    }
    
    .margin-lg {
      margin: 20px;
    }
    
    .margin-xl {
      margin: 25px;
    }
    
    .margin-top-xs {
      margin-top: 5px;
    }
    
    .margin-top-sm {
      margin-top: 10px;
    }
    
    .margin-top {
      margin-top: 15px;
    }
    
    .margin-top-lg {
      margin-top: 20px;
    }
    
    .margin-top-xl {
      margin-top: 25px;
    }
    
    .margin-right-xs {
      margin-right: 5px;
    }
    
    .margin-right-sm {
      margin-right: 10px;
    }
    
    .margin-right {
      margin-right: 15px;
    }
    
    .margin-right-lg {
      margin-right: 20px;
    }
    
    .margin-right-xl {
      margin-right: 25px;
    }
    
    .margin-bottom-xs {
      margin-bottom: 5px;
    }
    
    .margin-bottom-sm {
      margin-bottom: 10px;
    }
    
    .margin-bottom {
      margin-bottom: 15px;
    }
    
    .margin-bottom-lg {
      margin-bottom: 20px;
    }
    
    .margin-bottom-xl {
      margin-bottom: 25px;
    }
    
    .margin-left-xs {
      margin-left: 5px;
    }
    
    .margin-left-sm {
      margin-left: 10px;
    }
    
    .margin-left {
      margin-left: 15px;
    }
    
    .margin-left-lg {
      margin-left: 20px;
    }
    
    .margin-left-xl {
      margin-left: 25px;
    }
    
    .margin-lr-xs {
      margin-left: 5px;
      margin-right: 5px;
    }
    
    .margin-lr-sm {
      margin-left: 10px;
      margin-right: 10px;
    }
    
    .margin-lr {
      margin-left: 15px;
      margin-right: 15px;
    }
    
    .margin-lr-lg {
      margin-left: 20px;
      margin-right: 20px;
    }
    
    .margin-lr-xl {
      margin-left: 25px;
      margin-right: 25px;
    }
    
    .margin-tb-xs {
      margin-top: 5px;
      margin-bottom: 5px;
    }
    
    .margin-tb-sm {
      margin-top: 10px;
      margin-bottom: 10px;
    }
    
    .margin-tb {
      margin-top: 15px;
      margin-bottom: 15px;
    }
    
    .margin-tb-lg {
      margin-top: 20px;
      margin-bottom: 20px;
    }
    
    .margin-tb-xl {
      margin-top: 25px;
      margin-bottom: 25px;
    }
    
    .padding-0 {
      padding: 0;
    }
    
    .padding-xs {
      padding: 5px;
    }
    
    .padding-sm {
      padding: 10px;
    }
    
    .padding {
      padding: 15px;
    }
    
    .padding-lg {
      padding: 20px;
    }
    
    .padding-xl {
      padding: 25px;
    }
    
    .padding-top-xs {
      padding-top: 5px;
    }
    
    .padding-top-sm {
      padding-top: 10px;
    }
    
    .padding-top {
      padding-top: 15px;
    }
    
    .padding-top-lg {
      padding-top: 20px;
    }
    
    .padding-top-xl {
      padding-top: 25px;
    }
    
    .padding-right-xs {
      padding-right: 5px;
    }
    
    .padding-right-sm {
      padding-right: 10px;
    }
    
    .padding-right {
      padding-right: 15px;
    }
    
    .padding-right-lg {
      padding-right: 20px;
    }
    
    .padding-right-xl {
      padding-right: 25px;
    }
    
    .padding-bottom-xs {
      padding-bottom: 5px;
    }
    
    .padding-bottom-sm {
      padding-bottom: 10px;
    }
    
    .padding-bottom {
      padding-bottom: 15px;
    }
    
    .padding-bottom-lg {
      padding-bottom: 20px;
    }
    
    .padding-bottom-xl {
      padding-bottom: 25px;
    }
    
    .padding-left-xs {
      padding-left: 5px;
    }
    
    .padding-left-sm {
      padding-left: 10px;
    }
    
    .padding-left {
      padding-left: 15px;
    }
    
    .padding-left-lg {
      padding-left: 20px;
    }
    
    .padding-left-xl {
      padding-left: 25px;
    }
    
    .padding-lr-xs {
      padding-left: 5px;
      padding-right: 5px;
    }
    
    .padding-lr-sm {
      padding-left: 10px;
      padding-right: 10px;
    }
    
    .padding-lr {
      padding-left: 15px;
      padding-right: 15px;
    }
    
    .padding-lr-lg {
      padding-left: 20px;
      padding-right: 20px;
    }
    
    .padding-lr-xl {
      padding-left: 25px;
      padding-right: 25px;
    }
    
    .padding-tb-xs {
      padding-top: 5px;
      padding-bottom: 5px;
    }
    
    .padding-tb-sm {
      padding-top: 10px;
      padding-bottom: 10px;
    }
    
    .padding-tb {
      padding-top: 15px;
      padding-bottom: 15px;
    }
    
    .padding-tb-lg {
      padding-top: 20px;
      padding-bottom: 20px;
    }
    
    .padding-tb-xl {
      padding-top: 25px;
      padding-bottom: 25px;
    }
    

    边框

    /* -- 圆形或跑道形 -- */
    
    .round {
      border-radius: 10000px;
    }
    
    /* -- 1像素实线 -- */
    
    .solid,
    .solid-top,
    .solid-right,
    .solid-bottom,
    .solid-left,
    .solids,
    .solids-top,
    .solids-right,
    .solids-bottom,
    .solids-left,
    .dashed,
    .dashed-top,
    .dashed-right,
    .dashed-bottom,
    .dashed-left {
      position: relative;
    }
    
    .solid::after,
    .solid-top::after,
    .solid-right::after,
    .solid-bottom::after,
    .solid-left::after,
    .solids::after,
    .solids-top::after,
    .solids-right::after,
    .solids-bottom::after,
    .solids-left::after,
    .dashed::after,
    .dashed-top::after,
    .dashed-right::after,
    .dashed-bottom::after,
    .dashed-left::after {
      content: " ";
      width: 200%;
      height: 200%;
      position: absolute;
      top: 0;
      left: 0;
      border-radius: inherit;
      transform: scale(0.5);
      transform-origin: 0 0;
      pointer-events: none;
      box-sizing: border-box;
    }
    
    .solid::after {
      border: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .solid-top::after {
      border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .solid-right::after {
      border-right: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .solid-bottom::after {
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .solid-left::after {
      border-left: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .solids::after {
      border: 8upx solid #eee;
    }
    
    .solids-top::after {
      border-top: 8upx solid #eee;
    }
    
    .solids-right::after {
      border-right: 8upx solid #eee;
    }
    
    .solids-bottom::after {
      border-bottom: 8upx solid #eee;
    }
    
    .solids-left::after {
      border-left: 8upx solid #eee;
    }
    
    /* -- 1像素虚线 -- */
    
    .dashed::after {
      border: 1px dashed #ddd;
    }
    
    .dashed-top::after {
      border-top: 1px dashed #ddd;
    }
    
    .dashed-right::after {
      border-right: 1px dashed #ddd;
    }
    
    .dashed-bottom::after {
      border-bottom: 1px dashed #ddd;
    }
    
    .dashed-left::after {
      border-left: 1px dashed #ddd;
    }
    

    遮罩

    .bg-mask {
      position: relative;
    }
    
    .bg-mask::after {
      content: "";
      border-radius: inherit;
      width: 100%;
      height: 100%;
      display: block;
      background-color: rgba(0, 0, 0, 0.4);
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      top: 0;
    }
    

    文字

    .text-xs {
      font-size: 10px;
    }
    
    .text-sm {
      font-size: 12px;
    }
    
    .text-df {
      font-size: 14px;
    }
    
    .text-lg {
      font-size: 16px;
    }
    
    .text-xl {
      font-size: 18px;
    }
    
    .text-xxl {
      font-size: 22px;
    }
    
    .text-sl {
      font-size: 40px;
    }
    
    .text-xsl {
      font-size: 60px;
    }
    
    .text-Abc {
      text-transform: Capitalize;
    }
    
    .text-ABC {
      text-transform: Uppercase;
    }
    
    .text-abc {
      text-transform: Lowercase;
    }
    
    .lh-sm {
      line-height: 1.2;
    }
    
    .lh-df {
      line-height: 1.6;
    }
    
    .lh-lg {
      line-height: 2;
    }
    
    .text-price::before {
      content: "¥";
      font-size: 80%;
      margin-right: 8px;
    }
    
    .text-cut {
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden;
    }
    
    .text-bold {
      font-weight: bold;
    }
    
    .text-center {
      text-align: center;
    }
    
    .text-left {
      text-align: left;
    }
    
    .text-right {
      text-align: right;
    }
    

    相关文章

      网友评论

          本文标题:宇宙通用的CSS工具类整理

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