<div class="dropdown_main">
    <!-- 드롭다운 메뉴바 -->
    <div class="dropdown_bar">드롭다운 메뉴
        <svg class="drop_icon1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16">
            <path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/>
        </svg>
        <svg class="drop_icon2" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-up-fill" viewBox="0 0 16 16">
            <path d="m7.247 4.86-4.796 5.481c-.566.647-.106 1.659.753 1.659h9.592a1 1 0 0 0 .753-1.659l-4.796-5.48a1 1 0 0 0-1.506 0z"/>
        </svg>
    </div>

    <!-- 드롭다운 시 보여질 태그 -->
    <div class="dropdown_content">
        <a href="#"><div>· 하위 링크 1</div></a>
        <a href="#"><div>· 하위 링크 2</div></a>
        <a href="#"><div>· 하위 링크 3</div></a>
    </div>
</div>
body {
    text-align: center;
}

.dropdown_main {
    position: relative;
    display: inline-block;
    user-select: none;
}

.dropdown_bar {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
}

.dropdown_bar svg {
    vertical-align: middle;
    margin-left: 5px;
}

.dropdown_content {
    position: absolute;
    display: none;
    margin-top: 5px;
    width: 157px;
    background: linear-gradient(to bottom, #4a66ff, #b636cd);
    border-radius: 5%;
    box-shadow: 4px 4px 10px #c5b0b0;
    animation: fade-in 1s ease;
}

.dropdown_content a {
    text-align: left;
    color: #ffffff;
    padding: 0.5rem;
    text-decoration: none;
    display: block;
    font-size: 16px;
}

.drop_icon2 {
    display: none;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
var dropdown = document.querySelector(".dropdown_bar");
var dropdownContent = document.querySelector(".dropdown_content");
var drop_icon1 = document.querySelector(".drop_icon1");
var drop_icon2 = document.querySelector(".drop_icon2");

dropdown.addEventListener("click", function() {
  if (dropdownContent.style.display === "block") {
      dropdownContent.style.display = "none";
      drop_icon1.style.display = "inline-flex";
      drop_icon2.style.display = "none";
  } else {
      dropdownContent.style.display = "block";
      drop_icon1.style.display = "none";
      drop_icon2.style.display = "inline-flex";
  }
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.