下拉菜单中的箭头通常用于提示用户点击以展开菜单。CSS三角形实现这个箭头:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>CSS三角形应用示例 - 下拉菜单箭头</title> <style> body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: #f9f9f9; margin: 0; } .dropdown { position: relative; display: inline-block; } .dropdown-button { padding: 10px 20px; background-color: #3498db; color: white; font-size: 16px; border: none; cursor: pointer; display: flex; align-items: center; } .dropdown-arrow { margin-left: 10px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid white; } .dropdown-content { display: none; position: absolute; background-color: white; min-width: 160px; box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2); z-index: 1; margin-top: 10px; } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover { background-color: #f1f1f1; } .dropdown:hover .dropdown-content { display: block; } </style> </head> <body> <div class="dropdown"> <button class="dropdown-button"> 下拉菜单 <div class="dropdown-arrow"></div> </button> <div class="dropdown-content"> <a href="#">选项 1</a> <a href="#">选项 2</a> <a href="#">选项 3</a> </div> </div> </body> </html>标签:03,dropdown,--,content,color,用纯,background,border,display From: https://www.cnblogs.com/zx618/p/18370299