I am too newb...(solved)

Chat about just about anything else
Forum rules
Do not post support questions here. Before you post read the forum rules. Topics in this forum are automatically closed 30 days after creation.
Locked
T_Characht3r

I am too newb...(solved)

Post by T_Characht3r »

So, I'm trying to code a web page...
I ran into an issue with trying to put a button w/ a drop-down menu into a horizontal list (I used the code from W3schools.com)
I had this, and the button extended across the whole bar:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<style>
body {
    background-color: #0D0DFF
}
ul {
    list-style-type: none;
    margin: 0;
    padding: 0; 
    overflow: hidden;
    background-color: #333;
}

li {
    float: left;
    border-right:1px solid #bbb;
}

li:last-child {
    border-right: none;
}

li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

li a:hover:not(.active) {
    background-color: #111;
}

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

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

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

.dropdown-content a:hover {background-color: #ddd;}

.dropdown:hover .dropdown-content {display: block;}

.dropdown:hover .dropbtn {background-color: #3e8e41;}
</style>

<ul>

  <li><a class="active" href="index.htm">Home</a></li>
  <li><a href="content/store.htm">Shop</a></li>
  <li style="float:right"><a href="content/about.htm">About</a></li>
  <li style="float:right"><a href="content/help.htm">Help</a></li>

  <div class="dropdown">
  <button class="dropbtn">Dropdown</button>
  <div class="dropdown-content">
    <a href="#">Link 1</a>
    <a href="#">Link 2</a>
    <a href="#">Link 3</a>
  </div>
</div>

</ul>
</head>
</html>
How can I make the button have the right "hitbox" size?
Last edited by LockBot on Wed Dec 07, 2022 4:01 am, edited 1 time in total.
Reason: Topic automatically closed 30 days after creation. New replies are no longer allowed.
Locked

Return to “Open Chat”