代码片段

产生随机颜色
function randomVal(val) {
    return Math.floor(Math.random() * (val + 1));
}
   
function randomColor() {
    return `rgb(${randomVal(255}, ${randomVal(255}, ${randomVal(255})`;
}
渐变色按钮(边框+文字)


.btn {
    padding: 1px;
    color: #4cdbbc;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    border: none;
    background: -webkit-linear-gradient(left, #fff 0%, #fff 100%), linear-gradient(90deg, #47d998 0%, #01d5d8 100%);
    background-clip: content-box, padding-box;
}
.btn span {
     background: linear-gradient(90deg, #47d998 0%, #01d5d8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
向右的箭头(>)
.icon-v-right {
    width: 10px;
    height: 10px;
    border: 1px solid #dbdbdb;
    border-width: 1px 1px 0 0;
    transform: rotate(45deg);
}
translate居中
.center {
  position: absolute;
  top: 50%; /* 父元素高度的一半位置 */
  left: 50%; /* 父元素宽度的一半位置 */
  transform: translate(-50%, -50%); /* 元素本身的一半宽、高 */
}
请使用 animation 实现 loading 效果
/* 四分之一边框 loading */
.loading { width: 100px; height: 100px; margin: 60px auto; position: relative; border: 10px solid rgba(0, 0, 0, 0.2); border-top-color: #000; border-radius: 50%; animation: rotateLoading 1.1s linear infinite; } @keyframes rotateLoading { from { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
/* 柱子 loading */
 
.pillar-loading { width: 60px; display: flex; justify-content: space-between; margin: 100px auto; } .pillar-loading .pillar { width: 8px; height: 40px; border-radius: 4px; background: lightgreen; animation: pillarLoading 1s ease infinite; } .pillar-loading .pillar:nth-child(2) { animation-delay: 0.2s; } .pillar-loading .pillar:nth-child(3) { animation-delay: 0.4s; } .pillar-loading .pillar:nth-child(4) { animation-delay: 0.6s; } .pillar-loading .pillar:nth-child(5) { animation-delay: 0.8s; } @keyframes pillarLoading { 0%, 100% { background: lightgreen; } 50% { transform: scaleY(1.75); background: lightblue; } }
 /* 圆点 loading */
 
.point-loading { width: 100px; height: 100px; position: relative; margin: 100px auto 0; } .point-loading .point { position: absolute; width: 20px; height: 20px; border-radius: 50%; background: lightgreen; animation: pointLoading 1s infinite; } .point-loading .point:nth-child(1) { left: 0; top: 50%; margin-top: -10px; animation-delay: 0.13s; } .point-loading .point:nth-child(2) { left: 14px; top: 14px; animation-delay: 0.26s; } .point-loading .point:nth-child(3) { left: 50%; top: 0; margin-left: -10px; animation-delay: 0.39s; } .point-loading .point:nth-child(4) { top: 14px; right: 14px; animation-delay: 0.52s; } .point-loading .point:nth-child(5) { right: 0; top: 50%; margin-top: -10px; animation-delay: 0.65s; } .point-loading .point:nth-child(6) { right: 14px; bottom: 14px; animation-delay: 0.78s; } .point-loading .point:nth-child(7) { bottom: 0; left: 50%; margin-left: -10px; animation-delay: 0.91s; } .point-loading .point:nth-child(8) { bottom: 14px; left: 14px; animation-delay: 1.04s; } @keyframes pointLoading { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(.3); opacity: 0.5; } }

代码片段_第1张图片

白色半透明遮罩层
.mask {
    height: 100px;
    background-image: linear-gradient(0deg, rgba(255,255,255,1) 50%, rgba(255,255,255,.3));
}

你可能感兴趣的:(代码片段)