如何让谷歌适配12px的字体大小与如何画0.5px的边框线

82 阅读1分钟

适配12px的字体大小

画0.5px的边框线

box-shadow阴影实现

`.box{
    box-sizing: border-box;
    height: 200px;
    width: 200px;
    background-color: aqua;
    border: 1px solid red;
}`
`
    .box2{
    margin-top: 20px;
    box-sizing: border-box;
    height: 200px;
    width: 200px;
    background-color: aqua;
    /* border: 1px solid red; */
    box-shadow: 0px 0px 0px 0.5px green;
    
}
`

如图所示

image.png

设置伪类元素

   div {
        position: relative;
        box-sizing: border-box;
        background-color: blueviolet;
        width: 200px;
        height: 200px;
        margin-top: 10px;
        /* box-shadow: 0px 0px 0px 0.5px green; */
    }


  
  div::after {
        position: absolute;
        content: "";
        background-color: red;
        width: 100%;
        height: 0.5px;
        bottom: 0px;
    }
    `

transform 缩放实现

`div { position: relative; box-sizing: border-box; background-color: blueviolet; width: 200px; height: 200px; margin-top: 10px; /* box-shadow: 0px 0px 0px 0.5px green; */ }

    div::after {

        position: absolute;
        content: "";
        width: 200%;
        height: 200%;
        border: 1px solid red;
        transform-origin: 0 0;
        transform: scale(0.5);


    }

`