今天给大家分享的这个项目是 Lynn Fisher 创建的 A Single Div: a CSS drawing project

    可以点击查看:https://a.singlediv.com/

    我们找两个效果来看看,她是怎么实现的:

    image.png

    1. #css-three div {
    2. width: 300px;
    3. height: 100px;
    4. margin-left: -150px;
    5. margin-top: -50px;
    6. background-repeat: no-repeat;
    7. background-image: linear-gradient(to right,#f2612f 5.3%,transparent 5.3%,transparent 10%,#f2612f 10%,#f2612f 13%,transparent 13%),linear-gradient(65deg,transparent 44%,#f2612f 44%,#f2612f 49%,transparent 49%,transparent 53%,#f2612f 53%,#f2612f 56%,transparent 56%),linear-gradient(65deg,transparent 74%,#f2612f 74%,#f2612f 79%,transparent 79%,transparent 83%,#f2612f 83%,#f2612f 86%,transparent 86%);
    8. background-size: 100% 100%;
    9. background-position: 0 0;
    10. }
    11. #css-three div:before {
    12. width: 310px;
    13. height: 216px;
    14. left: 50%;
    15. top: -58px;
    16. margin-left: -155px;
    17. background-repeat: repeat-x;
    18. background-image: radial-gradient(circle at bottom,#42c3d0 22%,transparent 22%,transparent 45%,#242b33 45%,#242b33 66%,transparent 66%),radial-gradient(circle at top,#42c3d0 22%,transparent 22%,transparent 45%,#242b33 45%,#242b33 66%,transparent 66%);
    19. background-size: 33.333% 45px;
    20. background-position: 0 0,0 100%
    21. }
    22. #css-three div:after {
    23. width: 300px;
    24. height: 100px;
    25. background-repeat: no-repeat;
    26. background-image: radial-gradient(circle at top,#f2612f 14%,transparent 14%),radial-gradient(circle at top,#f2612f 14%,transparent 14%),radial-gradient(circle at top,#f2612f 14%,transparent 14%),radial-gradient(circle at bottom,#f2612f 14%,transparent 14%),radial-gradient(circle at bottom,#f2612f 14%,transparent 14%),radial-gradient(circle at bottom,#f2612f 14%,transparent 14%);
    27. background-size: 30% 100%;
    28. background-position: 15% 0,64% 0,114% 0,15% 100%,35% 100%,85% 100%
    29. }

    image.png

    1. #rey div {
    2. width: 90px;
    3. height: 140px;
    4. margin-left: -45px;
    5. margin-top: -70px;
    6. background-color: #d2b48c;
    7. border-radius: 100px 100px 110% 110%;
    8. -webkit-box-shadow: -3px 11px 0 -7px rgba(139,69,19,0.4),0 20px 0 -6px #caa778,inset 8px 0 0 rgba(0,0,0,0.07);
    9. box-shadow: -3px 11px 0 -7px rgba(139,69,19,0.4),0 20px 0 -6px #caa778,inset 8px 0 0 rgba(0,0,0,0.07);
    10. }
    11. #rey div:before {
    12. width: 70px;
    13. height: 80px;
    14. left: 50%;
    15. top: 34px;
    16. margin-left: -35px;
    17. background-color: #f5a968;
    18. background-repeat: no-repeat;
    19. background-image: radial-gradient(circle,rgba(255,255,255,0.6) 50%,transparent 50%),radial-gradient(circle,#4d523e 50%,transparent 50%),radial-gradient(circle,rgba(255,255,255,0.6) 50%,transparent 50%),radial-gradient(circle,#4d523e 50%,transparent 50%),radial-gradient(circle,#d29152 50%,transparent 50%),radial-gradient(circle,#d29152 50%,transparent 50%),radial-gradient(circle,#d29152 50%,transparent 50%),radial-gradient(circle,#d29152 50%,transparent 50%),radial-gradient(circle,#d29152 50%,transparent 50%),radial-gradient(circle,#d29152 50%,transparent 50%),radial-gradient(ellipse at 50% 120%,#cd853f 50%,transparent 50%),radial-gradient(ellipse at 50% 120%,#cd853f 50%,transparent 50%),radial-gradient(ellipse at 50% -20%,#cd853f 50%,transparent 50%);
    20. background-size: 4px 4px,14px 14px,4px 4px,14px 14px,3px 3px,3px 3px,3px 3px,3px 3px,3px 3px,3px 3px,15px 7px,15px 7px,18px 7px;
    21. background-position: 13px 33px,10px 30px,49px 33px,46px 30px,13px 48px,17px 53px,20px 48px,48px 48px,52px 53px,55px 48px,23px 55px,32px 55px,50% 62px;
    22. border-top-left-radius: 110px 80px;
    23. border-top-right-radius: 110px 80px;
    24. border-bottom-left-radius: 110px;
    25. border-bottom-right-radius: 110px;
    26. -webkit-box-shadow: inset 3px 0 rgba(0,0,0,0.2),inset -3px 0 rgba(0,0,0,0.2),inset 9px 0 rgba(0,0,0,0.1),inset -9px 0 rgba(0,0,0,0.1),3px 5px 0 5px #d2b48c,7px 14px 0 rgba(139,69,19,0.4);
    27. box-shadow: inset 3px 0 rgba(0,0,0,0.2),inset -3px 0 rgba(0,0,0,0.2),inset 9px 0 rgba(0,0,0,0.1),inset -9px 0 rgba(0,0,0,0.1),3px 5px 0 5px #d2b48c,7px 14px 0 rgba(139,69,19,0.4)
    28. }
    29. #rey div:after {
    30. width: 28px;
    31. height: 14px;
    32. left: 10px;
    33. top: 28px;
    34. background: #444;
    35. border-top-left-radius: 20px;
    36. border-top-right-radius: 20px;
    37. border-bottom-left-radius: 30px;
    38. border-bottom-right-radius: 30px;
    39. -webkit-box-shadow: -25px -5px 0 -6px #b08245,-25px 5px 0 -6px #b08245,65px -5px 0 -6px #b08245,65px 5px 0 -6px #b08245,40px 0 0 #444,0 0 0 8px #cba97a,40px 0 0 8px #cba97a,0 0 0 14px #b98b4d,40px 0 0 14px #b98b4d,0 4px 0 14px rgba(0,0,0,0.15),40px 4px 0 14px rgba(0,0,0,0.15);
    40. box-shadow: -25px -5px 0 -6px #b08245,-25px 5px 0 -6px #b08245,65px -5px 0 -6px #b08245,65px 5px 0 -6px #b08245,40px 0 0 #444,0 0 0 8px #cba97a,40px 0 0 8px #cba97a,0 0 0 14px #b98b4d,40px 0 0 14px #b98b4d,0 4px 0 14px rgba(0,0,0,0.15),40px 4px 0 14px rgba(0,0,0,0.15)
    41. }

    其他的效果,自己去看上面的网站吧,有没有觉得CSS的威力还是很强大的!