導航欄下劃線跟隨滑鼠
阿新 • • 發佈:2018-11-29
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>導航欄下劃線跟隨滑鼠</title> <style> ul{ list-style: none; font-size: 0; } li{ position: relative; display: inline-block; padding: 1rem; cursor: pointer; font-size: 16px; } li::after{ content: ''; width: 0; height: 0; position: absolute; bottom: 0; left: 100%; border-bottom: 1px solid black; transition: 0.3s ease; } li:hover::after{ width: 100%; left: 0; } li:hover~li::after { left: 0; } </style> </head> <body> <ul> <li>html</li> <li>css</li> <li>javasvript</li> <li>vue</li> <li>react</li> </ul> </body> </html>