x

Drop Down Box

Hi,

I'm new to Weebly, and am trying to create a drop down button box..  I have attempted to use the following code in an Embeded Code tag.. 

<style>
.dropbtn {
    background-color: #4CAF50;
    color: white;
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
}

.dropbtn:hover, .dropbtn:focus {
    background-color: #3e8e41;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    overflow: auto;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown a:hover {background-color: #f1f1f1}

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

<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Dropdown</button>
  <div id="myDropdown" class="dropdown-content">
    <a href="#home">Home</a>
    <a href="#about">About</a>
    <a href="#contact">Contact</a>
  </div>
</div>

<script>
/* When the user clicks on the button, 
toggle between hiding and showing the dropdown content */
function myFunction() {
    document.getElementById("myDropdown").classList.toggle("show");
}

// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
  if (!event.target.matches('.dropbtn')) {

    var dropdowns = document.getElementsByClassName("dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {
        openDropdown.classList.remove('show');
      }
    }
  }
}
</script>

This shows my green button, but when I click the button, nothing happens.. Any suggestions? Thanks.. 

2,967 Views
Message 1 of 4
Report
3 REPLIES 3

Hello!

We wouldn't be able to advise you on the code directly, but some of our Community members here may be able to troubleshoot for you, and let you know what parts to check out. What were you looking to do with the dropdown box?

2,960 Views
Message 2 of 4
Report

I'm adding an Event page with a Calendar on it.  I wanted to create a button for the user to press, and present them with options to switch between Month, Weekly or Agenda view...  Thanks. 

2,942 Views
Message 3 of 4
Report

So, I've made some progress on this...  

The problem is the overflow-y: hidden setting on the div containing my embed code section.  It seems that the embed code section is being wrapped in a <div> section which has the overflow-y: hidden setting.  How would I over ride that? 

2,918 Views
Message 4 of 4
Report
This thread has been archived and locked. Please start a new thread if you would like to continue the conversation.