<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title>圆柱体</title> <style> .yuanzhu { position: relative; height: 200px; width: 50px; background: linear-gradient(left, #0158a9, #0095cf); background: -ms-linear-gradient(left, #0158a9, #0095cf); background: -webkit-linear-gradient(left, #0158a9, #0095cf); background: -moz-linear-gradient(left, #0158a9, #0095cf); margin: 30px auto; z-index: 999 } .yuanzhu:before { position: absolute; top: -10px; content: ""; width: 50px; height: 20px; border-radius: 50%; background: #2193d0; z-index: 99 } .yuanzhu:after { position: absolute; bottom: -10px; content: ""; width: 50px; height: 20px; border-radius: 50%; background: linear-gradient(left, #0158a9, #0095cf); background: -ms-linear-gradient(left, #0158a9, #0095cf); background: -webkit-linear-gradient(left, #0158a9, #0095cf); background: -moz-linear-gradient(left, #0158a9, #0095cf); z-index: 9 } </style> </head><body> <div class="yuanzhu"></div></body></html>