다음은 CSS로 하단 테두리(밑줄) 탐색 링크를 생성하는 코드입니다. −
예시
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body { font-family: Arial, Helvetica, sans-serif; margin: 0; } nav { overflow: hidden; background-color: rgb(0, 52, 73); } nav .links { float: left; font-size: 16px; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } .subnav { float: left; overflow: hidden; } .subnav .sub-btn { font-size: 16px; border: none; outline: none; color: white; padding: 14px 16px; background-color: rgb(0, 109, 67); margin: 0; } nav .links:hover, .subnav:hover .sub-btn { background-color: rgb(101, 219, 255); color: black; font-weight: bolder; } .sub-content { display: none; position: absolute; left: 0; background-color: rgb(0, 156, 83); width: 100%; z-index: 1; } .sub-content a { float: left; color: white; text-decoration: none; } .sub-content a:hover { background-color: #eee; color: black; } .subnav:hover .sub-content { display: block; } </style> </head> <body> <nav> <a class="links" href="#">Home</a> <a class="links" href="#">Contact</a> <a class="links" href="#">About Us</a> <a class="links" href="#">More Info</a> <div class="subnav"> <button class="sub-btn">Our Social Media></button> <div class="sub-content"> <a class="links" href="#">Facebook</a> <a class="links" href="#">Twitter</a> <a class="links" href="#">LinkedIn</a> <a class="links" href="#">Instagram</a> </div> </div> </nav> </body> </html>
출력
위의 코드는 다음 출력을 생성합니다 -
드롭다운 버튼 위로 마우스를 가져갈 때 -