current position:Home>CSS foundation-15-drop-down menu
CSS foundation-15-drop-down menu
2022-04-29 14:01:12【Xuan Degong】
List of articles
1. Basic implementation
<!DOCTYPE html>
<html>
<head>
<title> Xuande... Chronicles </title>
<meta charset="utf-8">
<style> .dropdown {
position: relative; display: inline-block; } .dropdown-content {
display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); padding: 12px 16px; } .dropdown:hover .dropdown-content {
display: block; } </style>
</head>
<body>
<div class="dropdown">
<span> Choose generals </span>
<div class="dropdown-content">
<p> Guan yu </p>
<p> Zhang Fei </p>
<p> zhaoyun </p>
<p> d </p>
</div>
</div>
</body>
</html>
- effect
- inline-block
And display: inline comparison :
- display: inline-block Allows you to set the width and height on the element ( The top and bottom outer margins are retained / padding )
- display: inline Will not be .
And display: block comparison :
- display:inline-block Do not add line breaks after elements .( So this element can be next to other elements )
- display: block Add a line break after the element .
2. Add some effects
<!DOCTYPE html>
<html>
<head>
<title> Xuande... Chronicles </title>
<meta charset="utf-8">
<style> /* Drop down button style */ .dropbtn {
background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; /* Mouse to hand */ cursor: pointer; } /* Containers <div> - Need to locate the drop-down content */ .dropdown {
position: relative; display: inline-block; } /* Drop down content ( Hide by default ) */ .dropdown-content {
display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; /* Add shadow */ box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); } /* Drop down menu link */ .dropdown-content a {
color: black; padding: 12px 16px; text-decoration: none; display: block; } /* Move the mouse up and modify the link color of the drop-down menu */ .dropdown-content a:hover {
background-color: #f1f1f1} /* When the mouse moves up, the drop-down menu is displayed */ .dropdown:hover .dropdown-content {
display: block; } /* When the drop-down content is displayed, modify the background color of the drop-down button */ .dropdown:hover .dropbtn {
background-color: #3e8e41; } </style>
</head>
<body>
<div class="dropdown">
<button class="dropbtn"> Choose generals </button>
<div class="dropdown-content">
<a href="./guanyu.html"> Guan yu </a>
<a href="./zhangfei.html"> Zhang Fei </a>
<a href="./zhaoyun.html"> zhaoyun </a>
</div>
</div>
</body>
</html>
- effect
copyright notice
author[Xuan Degong],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291215151541.html
The sidebar is recommended
- How to create JavaScript custom events
- Is there any recommendation for wireless signal and wired signal power amplification circuit?
- Introduction to basic methods of math built-in objects in JavaScript
- 1000km pure electric endurance is meaningless? Then why does the car factory still try its best to extend the endurance?
- [let's implement a simple vite!] Chapter 4 - compiling single file components
- 3-11xss htmlspecialchars bypass demo
- How to conduct architecture design 𞓜 deeply reveal Alibaba cloud serverless kubernetes (2)
- Heapdump performance community special series 7: front door opener of large factory -- Application Practice of fluent
- 1、 HTML base tag
- Don't leave the crane unless necessary! A case of novel coronavirus nucleic acid positive was found in Heshan, Guangdong
guess what you like
[Architect (Part 20)] self defined template of scaffold and summary of phase I
How does JavaScript understand this algorithm
[live review] openharmony knowledge empowerment lesson 2, phase 5 - becoming a community talent
Understand the basic history and knowledge of HTTP
Influence of lazy loading of Web front-end training on Web Performance
Guangxi 2021 Guangxi landscape - blessing Lake Changshou Island
Responsive gulp Chinese network of web front end
Twaver-html5 basic learning (26) background
CSS learning notes [3] floating, not separated from document flow, inheritance and stacking
Webengine loading local html is invalid, and html is the dynamic address generated by JS, which can be solved
Random recommended
- Event handling of react
- Character coding knowledge that needs to be understood in front-end development
- 05. JavaScript operator
- 06. JavaScript statement
- Vue basics and some components
- Introduction to front-end Er excellent resources
- Node. Summary of methods of outputting console to command line in JS
- The beginning of passion, the ending of carelessness, python anti climbing, Jiageng, friends asked for MIHA's API and arranged y24 for him
- Technology sharing | test platform development - Vue router routing design for front-end development
- Node under windows JS installation detailed steps tutorial
- Layui built-in module (element common element operation)
- Excuse me, my eclipse Exe software has clearly opened to display the number of lines. Why is it useless
- It was revealed that Meila of Sea King 2 had less than ten minutes to appear, which was affected by negative news
- Vue element admin how to modify the height of component El tabs
- Bootstrap navigation bar drop-down menu does not take effect
- Vue Preview PDF file
- Geely joined the hybrid sedan market, and Toyota seemed even more hopeless
- Mustache template engine for exploring Vue source code
- Referer and referer policy and picture anti-theft chain
- Explain the "three handshakes" and "four waves" of TCP connection in detail
- Introduction to basic methods of math built-in objects in JavaScript
- JavaWeb Tomcat (III) httpservlet
- Vue Za wiper technical scheme
- Differences, advantages and disadvantages between HTTP negotiation cache Etag and last modified
- After taking tens of millions less, the management of Lenovo holdings took the initiative to reduce the salary by 70%
- What if Vue introduces this file and reports an error?
- Use Hikvision Web3 in vue3 2. Live broadcast without plug-in version (II)
- How to learn high-order function "zero basis must see"
- Detailed explanation of JS promise
- Cesium drawcommand [1] draw a triangle without talking about the earth
- The role of webpack cli in webpack packaging
- Action system of coco2d-x-html5
- Vxe table check box paging data memory selection problem
- [hand tear series] hand tear promise -- this article takes you to realize promise perfectly according to promise a + specification!
- QT use qdialog to realize interface mask (mask)
- Differences between JSP comments and HTML comments
- Bankless: Ethereum's data report and ecological highlights in the first quarter of 22 years
- Spring mvc07: Ajax research
- Understand the basic history and knowledge of HTTP
- Technology sharing | learning to do test platform development vuetify framework