shaozj / blog

blog
87 stars 4 forks source link

30+有用css代码片段 #1

Open shaozj opened 7 years ago

shaozj commented 7 years ago

原文:http://webres.wang/31-css-code-snippets-to-make-you-a-better-coder/?utm_source=tuicool&utm_medium=referral

1、垂直对齐

.vc {
    position: relative;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -o-transform: translateY(-50%);
    transform: translateY(-50%);
}

2、只在一侧或两侧具有投影

.box-shadow {
    background-color: #AC92EC;
    width: 160px;
    height: 90px;
    margin-top: -45px;
    margin-left: -80px;
    position: absolute;
    top: 50%;
    left: 50%;
}

.box-shadow:after {
    content: "";
    width: 150px;
    height: 1px;
    margin-top: 88px;
    margin-left: -75px;
    display: block;
    position: absolute;
    left: 50%;
    z-index: -1;
    -webkit-box-shadow: 0px 0px 8px 2px #000000;
       -moz-box-shadow: 0px 0px 8px 2px #000000;
            box-shadow: 0px 0px 8px 2px #000000;
}

3、渐变背景动画效果

。。。未完待续

。。。