Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:25:06+00:00 2026-05-15T20:25:06+00:00

Hi I have a dropdown button that when you hover it, it drops down

  • 0

Hi I have a dropdown button that when you hover it, it drops down some links to pages. I want those links to be the same size as the width of the button.

The button size is 100% width of the content, so it varies. How do I make the size of the drop down items the same size as the button with CSS?

    <style type="text/css">
      #button {  /* Box in the button */
        display: block;
        width: 190px;
      }

      #button a {
        text-decoration: none;  /* Remove the underline from the links. */
      }
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li{
float:left;
list-style-type: none;
}
      #button ul {
        list-style-type: none;  /* Remove the bullets from the list */
      }

      #button .top {
display:block;
width:100%;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;  /* The button background */
      }

      #button ul li.item {
        display: none;  /* By default, do not display the items (which contains the links) */
      }  

      #button ul:hover .item {  /* When the user hovers over the button (or any of the links) */
        display: block;

        border: 1px solid black;
        background-color: #6CC417;
      }
a:link,a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#7A991A;


}
.container
{
text-align:center;
}

.center_div
{
border:1px solid gray;
margin-left:auto;
margin-right:auto;
width:90%;
background-color:#d0f0f6;
text-align:left;
padding:8px;
}

    </style>
</head>
<body bgcolor="#FFFFFF">

<p><img src="Screen%20shot%202010-07-11%20at%204.07.59%20PM.png" width="211" height="86" alt="idc"> 

<ul>
<li>
    <div id="button">
      <ul>
        <li class="top">OtherOverflow Sites</li>
        <li class="item"><a href="http://serverfault.com/">Visit serverfault</a></li>
        <li class="item"><a href="http://superuser.com/">Visit superuser</a></li>
        <li class="item"><a href="http://doctype.com/">Visit doctype</a></li>
      </ul>
    </div>
</li>
<li>
    <div id="button">
      <ul>
        <li class="top">OtherOverflow Sites</li>
        <li class="item"><a href="http://serverfault.com/">Visit serverfault</a></li>
        <li class="item"><a href="http://superuser.com/">Visit superuser</a></li>
        <li class="item"><a href="http://doctype.com/">Visit doctype</a></li>
      </ul>
    </div>
</li>
</ul></p>
<div class="container">
<div class="center_div">
<h1>Hello World!</h1>
<p>This example contains some advanced CSS methods you may not have learned yet. But, we will explain these methods in a later chapter in the tutorial.</p>
</div>
</div>
</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:25:06+00:00Added an answer on May 15, 2026 at 8:25 pm

    Three things:

    1. #button ul:hover .item needs width set to 100%.

        #button ul:hover .item {any of the links) */
          display: block;
          width:100%;
          border: 1px solid black;
          background-color: #6CC417;
        }
      

      .

    2. All links are set to 120px!

      a:link,a:visited {
        display:block;
        width:120px;
        ...
      

      Delete the width:120px;

    3. As meder said, Do not use an id, use a class. And the code has the same id multiple times — which is illegal.

      So: <div id="button"> becomes: <div class="DropDwnMenuBtn">.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button <a> that should toggle a drop-down Then it should also
I have a button 'button' that activates a dropdown box 'box': $('.button').click(function() { $(this).siblings(.box).toggle();
I have some drop down menus that don't seem to be aligning nicely in
I have an options button that, when clicked on, will display a dropdown list
I have a drop down menu button. On hover of the button I need
I have two dropdown ddlCountry and ddlState and one button Submit. While ddlstate is
I have a jsp where some radio buttons and textboxes depend on dropdown selection.
I have a dropdown menu that pulls in text from a database column. The
I have a dropdown menu that I am using and can't quite get it
So i have this dropdown made in html/css/js.. it slides down on mouseover, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.