实用css

作者: 在下高姓 | 来源:发表于2020-09-29 23:17 被阅读0次

    标签: css


    正文

    1.图像灰度

    img {
        filter: gray; 
        -webkit-filter: grayscale(1);
    }
    

    2.文本自动换行

    pre {
        white-space: pre-line;
        word-wrap: break-word;
    }
    

    3.模糊文本

    .text {
       filter: blur(1px);
    }
    

    4.css动态省略号

    .point:after {
        overflow: hidden;
        display: inline-block;
        vertical-align: bottom;
        animation: ellipsis 2s infinite;
        content: "\2026";
    }
    @keyframes ellipsis {
        from {
            width: 2px;
        }
        to {
            width: 15px;
        }
    }
    
    

    5.样式重置

    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
      margin: 0;
      padding: 0;
      border: 0;
      font-size: 100%;
      font: inherit;
      vertical-align: baseline;
      outline: none;
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      box-sizing: border-box;
    }
    html { height: 101%; }
    body { font-size: 62.5%; line-height: 1; font-family: Arial, Tahoma, sans-serif; }
    article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
    ol, ul { list-style: none; }
    blockquote, q { quotes: none; }
    blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
    strong { font-weight: bold; } 
    table { border-collapse: collapse; border-spacing: 0; }
    img { border: 0; max-width: 100%; }
    p { font-size: 1.2em; line-height: 1.0em; color: #333; }
    
    

    6.通用媒体查询

    @media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
      /* Styles */
    }
    @media only screen and (min-width : 321px) {
      /* Styles */
    }
    @media only screen and (max-width : 320px) {
      /* Styles */
    }
    /* iPad */
    @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
      /* Styles */
    }
    @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
      /* Styles */
    }
    
    @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
      /* Styles */
    }
    /* 桌面 */
    @media only screen and (min-width : 1224px) {
      /* Styles */
    }
    
    @media only screen and (min-width : 1824px) {
      /* Styles */
    }
    
    @media only screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (min-device-pixel-ratio:1.5) {
      /* Styles */
    }
    
    
    

    7.自定义文本选择

    ::selection { background: #e2eae2; }
    

    8.图片边框偏光

    img.polaroid {
        background:#000; 
        border:solid #fff;
        border-width:6px 6px 20px 6px;
        box-shadow:1px 1px 5px #333; 
        -webkit-box-shadow:1px 1px 5px #333;
        -moz-box-shadow:1px 1px 5px #333;
        height:200px; 
        width:200px;  
    }
    
    

    9.列文本

    .columnsText {
        text-align: justify;
        -webkit-column-count: 3;
        -webkit-column-gap: 12px;
        -webkit-column-rule: 1px solid #c4c8cc;
    }
    
    

    10.显示a标签地址

    @media print   {  
      a:after {  
        content: " [" attr(href) "] ";  
      }  
    }
    

    11.消除transition闪屏

    .css {
        transform: translate3d(0,0,0);
    }
    

    12.writing-mode

    //writing-mode 属性定义了文本水平或垂直排布以及在块级元素中文本的行进方向。
    
    horizontal-tb:对于左对齐(ltr)脚本,内容从左到右水平流动。对于右对齐(rtr)脚本,内容从右到左水平流动。下一水平行位于上一行下方。
    
    vertical-rl:对于左对齐(ltr)脚本,内容从上到下垂直流动,下一垂直行位于上一行左侧。对于右对齐(rtr)脚本,内容从下到上垂直流动,下一垂直行位于上一行右侧。
    
    vertical-lr:对于左对齐(ltr)脚本,内容从上到下垂直流动,下一垂直行位于上一行右侧。对于右对齐(rtr)脚本,内容从下到上垂直流动,下一垂直行位于上一行左侧。
    
    

    13.font-variant-numeric

    //font-variant-numeric CSS属性控制数字,分数和序号标记的替代字形的使用。
    它采用以下这些值之一: normal | ordinal | slashed-zero | lining-nums | oldstyle-nums | proportional-nums | tabular-nums | diagonal-fractions | stacked-fractions。
    

    14. background-clip

    //backgroundclip CSS属性设置元素的背景是否扩展到其border 、padding 或content 框之下。
    
    

    15.shape-outside

    shape-outside的CSS 属性定义了一个可以是非矩形的形状,相邻的内联内容应围绕该形状进行包装。 默认情况下,内联内容包围其边距框; shape-outside提供了一种自定义此包装的方法,可以将文本包装在复杂对象周围而不是简单的框中。它采用与clip-path相同的值。
    

    相关文章

      网友评论

          本文标题:实用css

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