Özel Seçim Kutusu

16.08.2025 118 indirme Formlar
Ücretsiz

Stilize edilmiş dropdown menü

Canlı Önizleme
Bu önizlemede kod ile etkileşime geçebilirsiniz.
Kod
<style>
.custom-select {
  position: relative;
  width: 250px;
  font-family: Arial, sans-serif;
}

.select-selected {
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.select-selected:after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #333;
}

.select-items {
  position: absolute;
  background-color: white;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 99;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.select-items div {
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.select-items div:hover {
  background-color: #f1f1f1;
}

.select-hide {
  display: none;
}

.select-show {
  display: block;
}
</style>

<div class="custom-select">
  <div class="select-selected">Bir seçenek seçin</div>
  <div class="select-items select-hide">
    <div>Seçenek 1</div>
    <div>Seçenek 2</div>
    <div>Seçenek 3</div>
    <div>Seçenek 4</div>
    <div>Seçenek 5</div>
  </div>
</div>

<script>
document.querySelector(".select-selected").addEventListener("click", function() {
  document.querySelector(".select-items").classList.toggle("select-show");
  document.querySelector(".select-items").classList.toggle("select-hide");
});

const items = document.querySelectorAll(".select-items div");
items.forEach(item => {
  item.addEventListener("click", function() {
    document.querySelector(".select-selected").textContent = this.textContent;
    document.querySelector(".select-items").classList.add("select-hide");
    document.querySelector(".select-items").classList.remove("select-show");
  });
});

window.addEventListener("click", function(e) {
  if (!e.target.closest(".custom-select")) {
    document.querySelector(".select-items").classList.add("select-hide");
    document.querySelector(".select-items").classList.remove("select-show");
  }
});
</script>
Kullanım Talimatları
  1. Yukarıdaki kodu kopyalayın veya indirin
  2. HTML dosyanızın <head> bölümüne CSS kodlarını ekleyin
  3. JavaScript kodları varsa </body> etiketinden önce ekleyin
  4. HTML yapısını istediğiniz yere yerleştirin
  5. Gerekirse CSS sınıflarını projenize uygun şekilde düzenleyin
Kod Bilgileri
118
İndirme
Ücretsiz
Fiyat

16.08.2025 eklendi
Paylaş