Last active
December 28, 2024 11:10
-
-
Save kouameYao/97ede0facb5ce53c6d66a5a035b8b408 to your computer and use it in GitHub Desktop.
Pratique DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="fr"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Dropdown Recherchable</title> | |
<link rel="stylesheet" href="styles.css" /> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="dropdown-container"> | |
<div class="dropdown-input"> | |
<input type="text" id="searchInput" placeholder="Rechercher..." /> | |
<span class="arrow">▼</span> | |
</div> | |
<div class="dropdown-list" id="dropdownList"></div> | |
</div> | |
</div> | |
<script src="script.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: Arial, sans-serif; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
min-height: 100vh; | |
margin: 0; | |
background-color: #f5f5f5; | |
} | |
.container { | |
width: 100%; | |
max-width: 300px; | |
padding: 20px; | |
border: 1px solid green; | |
} | |
.dropdown-container { | |
position: relative; | |
width: 100%; | |
} | |
.dropdown-input { | |
position: relative; | |
width: 100%; | |
} | |
input { | |
width: 100%; | |
height: 3.5rem; | |
padding: 10px 30px 10px 10px; | |
border: 1px solid; | |
border-radius: 10px; | |
font-size: 14px; | |
box-sizing: border-box; | |
} | |
input:focus { | |
outline: none; | |
border-color: #007bff; | |
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25); | |
} | |
input::placeholder { | |
font-size: large; | |
font-style: italic; | |
} | |
.arrow { | |
position: absolute; | |
right: 10px; | |
top: 50%; | |
transform: translateY(-50%); | |
color: #666; | |
pointer-events: none; | |
transition: transform 0.2s ease; | |
} | |
.arrow.open { | |
transform: translateY(-50%) rotate(180deg); | |
} | |
.dropdown-list { | |
display: none; | |
position: absolute; | |
top: 100%; | |
left: 0; | |
right: 0; | |
background: white; | |
border: 1px solid #ddd; | |
border-radius: 10px; | |
margin-top: 4px; | |
max-height: 200px; | |
overflow-y: auto; | |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | |
z-index: 99; | |
} | |
.dropdown-list.show { | |
display: block; | |
} | |
.dropdown-item { | |
padding: 15px 10px; | |
cursor: pointer; | |
} | |
.dropdown-item:hover { | |
background-color: #ddd; | |
} | |
.no-results { | |
padding: 15px 10px; | |
color: #666; | |
font-style: italic; | |
font-size: large; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment