Skip to content

PHP

dropdown menu 간단 버전

Author
siwon
Date
2024-04-30 17:58
Views
418

<div class="dropdown">

  <button onclick="toggleDropdown()">Dropdown</button>

  <div id="dropdownContent" class="dropdown-content">

    <a href="#">Option 1</a>

    <a href="#">Option 2</a>

    <a href="#">Option 3</a>

  </div>

</div>



/* Style the dropdown button */

.dropdown button {

  background-color: #4CAF50;

  color: white;

  padding: 10px;

  font-size: 16px;

  border: none;

}


/* Style the dropdown content (hidden by default) */

.dropdown-content {

  display: none;

  position: absolute;

  background-color: #f9f9f9;

  min-width: 160px;

  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);

  z-index: 1;

}


/* Style links inside the dropdown */

.dropdown-content a {

  color: black;

  padding: 12px 16px;

  text-decoration: none;

  display: block;

}


/* Change color of dropdown links on hover */

.dropdown-content a:hover {

  background-color: #f1f1f1;

}


/* Show the dropdown menu when the button is clicked */

.show {

  display: block;

}

/* Style the dropdown button */

.dropdown button {

  background-color: #4CAF50;

  color: white;

  padding: 10px;

  font-size: 16px;

  border: none;

}


/* Style the dropdown content (hidden by default) */

.dropdown-content {

  display: none;

  position: absolute;

  background-color: #f9f9f9;

  min-width: 160px;

  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);

  z-index: 1;

}


/* Style links inside the dropdown */

.dropdown-content a {

  color: black;

  padding: 12px 16px;

  text-decoration: none;

  display: block;

}


/* Change color of dropdown links on hover */

.dropdown-content a:hover {

  background-color: #f1f1f1;

}


/* Show the dropdown menu when the button is clicked */

.show {

  display: block;

}

 function toggleDropdown() {

  var dropdownContent = document.getElementById("dropdownContent");

  dropdownContent.classList.toggle("show");

}


// Close the dropdown menu if the user clicks outside of it

window.onclick = function(event) {

  if (!event.target.matches('.dropdown button')) {

    var dropdowns = document.getElementsByClassName("dropdown-content");

    for (var i = 0; i < dropdowns.length; i++) {

      var openDropdown = dropdowns[i];

      if (openDropdown.classList.contains('show')) {

        openDropdown.classList.remove('show');

      }

    }

  }

}




------------------------------------------------------------------------------------------------------------------------

 

<script src="https://cdn.tailwindcss.com"></script>

 


<style>

.arrow {

  border: solid white;

  border-width: 0 3px 3px 0;

  display: inline-block;

  padding: 2px;

}


.right {

  transform: rotate(-45deg);

  -webkit-transform: rotate(-45deg);

}


.left {

  transform: rotate(135deg);

  -webkit-transform: rotate(135deg);

}


.up {

  transform: rotate(-135deg);

  -webkit-transform: rotate(-135deg);

}


.down {

  transform: rotate(45deg);

  -webkit-transform: rotate(45deg);

}

</style>


 

 

 




                <div class="relative inline-block text-left">

  <button type="" onclick="toggleDropdown(1)" class="btn btn-primary btn-xl page-scroll inline-flex justify-center w-full rounded-full  border border-gray-300 shadow-sm

      hover:bg-gray-50 hover:text-gray-900 focus:outline-none  ">

    MD STAFF

   <i class="arrow down ml-3 mt-1"></i>

  </button>


  <div id="dropdownContent1" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" 

  style="display: none;">

    <div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">

    <a href="https://md.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">MD APL Management</a>

      <a href="https://collect.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">MD UPC Collect</a>

      <a href="https://upc.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">MD APL Checker</a>

    </div>

  </div>

</div>

 


                <div class="relative inline-block text-left">

  <button type="" onclick="toggleDropdown(2)" class="btn btn-primary btn-xl page-scroll inline-flex justify-center w-full rounded-full  border border-gray-300 shadow-sm

      hover:bg-gray-50 hover:text-gray-900 focus:outline-none   ">

    VI STAFF

    <i class="arrow down ml-3 mt-1"></i>

  </button>


  <div id="dropdownContent2" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" 

  style="display: none;">

    <div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">

      <a href="https://vi.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">VI APL Management</a>

      <a href="https://vicollect.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">VI UPC Collect</a>

      <!-- <a href="https://upc.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">APL Checker</a> -->

    </div>

  </div>

</div>

                 

                <div class="relative inline-block text-left">

  <button type="" onclick="toggleDropdown(3)" class="btn btn-primary btn-xl page-scroll inline-flex justify-center w-full rounded-full  border border-gray-300 shadow-sm

      hover:bg-gray-50 hover:text-gray-900 focus:outline-none  ">

    VENDORS 

    

    <i class="arrow down ml-3 mt-1"></i>

  </button>

  <div id="dropdownContent3" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" 

  style="display: none;">

    <div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">

    <a href="https://up.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">MD UPC Upload</a>

       <a href="https://upc.wicapl.org" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">MD APL Checker</a>

    </div>

  </div>

</div>

 

                <div class="relative inline-block text-left">

                  <a href="tutorial/index.php">

  <button type=""   class="btn btn-success btn-xl page-scroll inline-flex justify-center w-full rounded-full  border border-gray-300 shadow-sm

      hover:bg-gray-50 hover:text-gray-900 focus:outline-none  ">

    TUTORIALS

 

  </button>

</a>

 

</div> 

 






        <script>


function toggleDropdown(a) {

  var dropdownContent = document.getElementById("dropdownContent"+a);

 // console.log(a);

 // console.log(dropdownContent);


  if (dropdownContent.style.display === "none") {

    dropdownContent.style.display = "block";

  } else {

    dropdownContent.style.display = "none";

  }

}


// Close the dropdown menu if the user clicks outside of it

window.onclick = function(event) {

  if (!event.target.matches('.inline-flex')) {

    var dropdowns = document.getElementsByClassName("origin-top-right");

    for (var i = 0; i < dropdowns.length; i++) {

      var openDropdown = dropdowns[i];

      if (openDropdown.style.display === "block") {

        openDropdown.style.display = "none";

      }

    }

  }

}



</script>



 

 

Total 0

Total 44
Number Title Author Date Votes Views
39
html center 중앙정렬 tailwind
siwon | 2024.07.27 | Votes 0 | Views 345
siwon 2024.07.27 0 345
38
dropdown menu alpinejs 사용 버전
siwon | 2024.04.30 | Votes 0 | Views 463
siwon 2024.04.30 0 463
37
dropdown menu 간단 버전
siwon | 2024.04.30 | Votes 0 | Views 418
siwon 2024.04.30 0 418
36
The Standard PHP Library (SPL) is a collection of classes and interfaces that provide core functionality to PHP developers.
siwon | 2023.10.24 | Votes 0 | Views 690
siwon 2023.10.24 0 690
35
session 과 쿠키
siwon | 2023.10.24 | Votes 0 | Views 531
siwon 2023.10.24 0 531
34
Late Static Binding (LSB):메서드 내부에서 현재 클래스의 정적 메서드 또는 프로퍼티를 호출할 때 사용
siwon | 2023.10.24 | Votes 0 | Views 547
siwon 2023.10.24 0 547
33
PHP 예외 처리(Exception Handling)
siwon | 2023.10.10 | Votes 0 | Views 568
siwon 2023.10.10 0 568
32
php exception
siwon | 2023.10.10 | Votes 0 | Views 1002
siwon 2023.10.10 0 1002
31
예외(Exception)를 처리하기 위해 try...catch 블록을 사용하는 방법
siwon | 2023.10.10 | Votes 0 | Views 601
siwon 2023.10.10 0 601
30
Preserving Parent Class Functionality in overriding
siwon | 2023.09.26 | Votes 0 | Views 473
siwon 2023.09.26 0 473
29
oop 세부항목
siwon | 2023.09.26 | Votes 0 | Views 475
siwon 2023.09.26 0 475
28
method chaining
siwon | 2023.09.25 | Votes 0 | Views 536
siwon 2023.09.25 0 536
27
interface implements
siwon | 2023.09.19 | Votes 0 | Views 459
siwon 2023.09.19 0 459
Re:interface implements
siwon | 2023.10.24 | Votes 0 | Views 394
siwon 2023.10.24 0 394
26
abstract class : 부모 class로 사용되며 자식(extends 한)에게 abstract method를 강제함(그들만의 방식으로)
siwon | 2023.09.19 | Votes 0 | Views 471
siwon 2023.09.19 0 471
25
isset() / unset()
siwon | 2023.09.18 | Votes 0 | Views 483
siwon 2023.09.18 0 483
24
magic methods-어떤 상황이 되면 call 하지 않아도 자동으로 실행되는 메소드
siwon | 2023.09.18 | Votes 0 | Views 480
siwon 2023.09.18 0 480
23
MD(markdown) file
siwon | 2023.09.12 | Votes 0 | Views 516
siwon 2023.09.12 0 516
22
usort
siwon | 2023.08.30 | Votes 0 | Views 482
siwon 2023.08.30 0 482
21
closure=unanimous function
siwon | 2023.08.30 | Votes 0 | Views 537
siwon 2023.08.30 0 537
php 7.4에서 추가 화살표 함수 fn()=>
siwon | 2023.10.24 | Votes 0 | Views 828
siwon 2023.10.24 0 828
20
reference variable &
siwon | 2023.08.29 | Votes 0 | Views 540
siwon 2023.08.29 0 540
참조(reference)한 original variable의 값을 바꿔버리기 때문에 조심해서 써야함
siwon | 2023.08.30 | Votes 0 | Views 569
siwon 2023.08.30 0 569
19
PHP 변수 : 스칼라(Scalar), 복합(Composite), 그리고 리소스(Resource)
siwon | 2023.08.22 | Votes 0 | Views 577
siwon 2023.08.22 0 577
18
if : vs {}
siwon | 2023.08.22 | Votes 0 | Views 444
siwon 2023.08.22 0 444
17
null coalescing operator
siwon | 2023.08.18 | Votes 0 | Views 548
siwon 2023.08.18 0 548
16
arrary functions
siwon | 2023.08.18 | Votes 0 | Views 457
siwon 2023.08.18 0 457
15
http request form method GET POST
siwon | 2023.08.17 | Votes 0 | Views 511
siwon 2023.08.17 0 511