1. <!DOCTYPE html>
    2. <html>
    3. <head lang="en">
    4. <meta charset="UTF-8">
    5. <title>圆柱体</title>
    6. <style>
    7. .yuanzhu {
    8. position: relative;
    9. height: 200px;
    10. width: 50px;
    11. background: linear-gradient(left, #0158a9, #0095cf);
    12. background: -ms-linear-gradient(left, #0158a9, #0095cf);
    13. background: -webkit-linear-gradient(left, #0158a9, #0095cf);
    14. background: -moz-linear-gradient(left, #0158a9, #0095cf);
    15. margin: 30px auto;
    16. z-index: 999
    17. }
    18. .yuanzhu:before {
    19. position: absolute;
    20. top: -10px;
    21. content: "";
    22. width: 50px;
    23. height: 20px;
    24. border-radius: 50%;
    25. background: #2193d0;
    26. z-index: 99
    27. }
    28. .yuanzhu:after {
    29. position: absolute;
    30. bottom: -10px;
    31. content: "";
    32. width: 50px;
    33. height: 20px;
    34. border-radius: 50%;
    35. background: linear-gradient(left, #0158a9, #0095cf);
    36. background: -ms-linear-gradient(left, #0158a9, #0095cf);
    37. background: -webkit-linear-gradient(left, #0158a9, #0095cf);
    38. background: -moz-linear-gradient(left, #0158a9, #0095cf);
    39. z-index: 9
    40. }
    41. </style>
    42. </head>
    43. <body>
    44. <div class="yuanzhu"></div>
    45. </body>
    46. </html>