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

  • Home
  • SEARCH
  • 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 7988385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:25:54+00:00 2026-06-04T12:25:54+00:00

I am trying to create a dropdown menu that when you click it will

  • 0

I am trying to create a dropdown menu that when you click it will open up a ul. The thing is I want the “View More” button to always be exactly where it is and the dropdown to open up centered below it.

if you go to the link below you will see what i mean. it opens up exactly like I want it to, but if you close the dropdown by clicking “View More” you will see the header move to the left when i want it to stay exactly where it is

I am building this to be able to be used in many many different locations so “hardcoding” sizes is not an option.

Please help! 🙂

HTML

<div id="testcontainer">

        <a href="javascript:;" class="dropdown-activator" dropdownContent="#dropdown-content-340">
            <span>View More!</span>
        </a>

        <ul class="dropdown-content" id="dropdown-content-340">
            <li><a href="http://www.google.com" class="googleIcon">Google</a></li>
            <li><a href="http://www.yahoo.com" class="yahooIcon">Yahoo</a></li>
            <li><a href="http://www.bing.com" class="bingIcon">Bing</a></li>
        </ul>


    </div>

    <div id="testcontainer2">

        <a href="javascript:;" class="dropdown-activator" dropdownContent="#dropdown-content-350">
            <span>View More!</span>
        </a>

        <ul class="dropdown-content" id="dropdown-content-350">
            <li><a href="http://www.google.com" class="googleIcon">Google</a></li>
            <li><a href="http://www.yahoo.com" class="yahooIcon">THIS IS A TEST FOR WIDER SHIT</a></li>
            <li><a href="http://www.bing.com" class="bingIcon">Bing</a></li>
        </ul>

    </div>

    <div id="testcontainer3">

        <a href="javascript:;" class="dropdown-activator" dropdownContent="#dropdown-content-400">
            <span>View More!</span>
        </a>

        <ul class="dropdown-content" id="dropdown-container-400">
            <li><a href="http://www.google.com" class="googleIcon">GOOOOOOOOOOOOOOOOOOOOOGLEASDASDSASD</a></li>
            <li><a href="http://www.yahoo.com" class="yahooIcon">Yahoo</a></li>
            <li><a href="http://www.bing.com" class="bingIcon">Bing</a></li>
        </ul>

    </div>

CSS

#testcontainer {
position: absolute;
top: 20px;
left: 100px;
text-align: center;
}

#testcontainer2 {
position: absolute;
top: 20px;
left: 150px;
text-align: center;
}

#testcontainer3 {
position: absolute;
top: 200px;
left: 500px;
text-align: center;
}

.dropdown-activator-active {
background-color: #000;
color: #fff;
}

.dropdown a {
display: inline-block;
}

.dropdown-activator {
display: inline-block;
border: 1px solid black;
padding: 3px;
}


.dropdown-content {
visibility: hidden;
height: 0;
opacity: 0;
position: relative;
text-align: left;
margin: 0 auto;
border: 1px solid black;
}

.dropdown-content-active {
visibility: visible;
height: auto;
opacity: 1;
}

.dropdown-content ul li {
list-style: none;
}

JQuery

$(function(){

$(".dropdown-activator").click(function() {
    $this = $(this);
    var current = $this.attr('dropdownContent');
    if (!$(current).hasClass('dropdown-content-active')) {
        $this.addClass("dropdown-activator-active", 100);
        $(current).addClass('dropdown-content-active', 100, function() {
            $('html').unbind('click');
            $('html').not($this).one('click', function() {
                $(current).prev().removeClass("dropdown-activator-active", 100);
                $(current).removeClass('dropdown-content-active', 100);
            });
        });
    } else {
        $this.removeClass("dropdown-activator-active", 100);
        $(current).removeClass('dropdown-content-active', 100)
    }
});
});

you can see an example of it here http://www.chrisworrell.com (temporary)

  • 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-06-04T12:25:59+00:00Added an answer on June 4, 2026 at 12:25 pm

    display: none; removes your element from the document flow, which is why your parent div resizes. On the other hand, visibility: hidden; hides your element while keeping it in the document flow.

    What you could do is instead of manipulating the display property of your <ul> element, set visibility: hidden; and height: 0; That way the unexpanded link will continue to use the width of the UL element it is bundled with.

    It’s kind of hacky, but should get the job done.

    In order to manipulate visibility instead of display none with jQuery UI, use .animate({opacity: 1}) for fadeIn() and .animate({opacity: 0}) for fadeOut()

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

Sidebar

Related Questions

I am trying to create a menu where users can view a menu that
I am trying to create a Dynamic Dropdown menu class which contains a class
I'm trying to create a dropdown kind of menu.So on clicking on a div
I am trying to create dropdown menu for Wordpress theme and having some silly
I am trying to create this dropdown box that slides down and has the
I'm trying to create a menu that works like the android notification drop-down area.
I am trying to create a dropdown menu based on Stu Nicholls' : http://www.cssplay.co.uk/menus/pro_drop8.html
I am trying to create a dropdown menu and i need to detect the
OK, so. I'm trying to create a dropdown menu of sorts using fadeToggle(). http://westrock.juggernautwebsites.com/
I'm trying to create a page with a navigation bar that has dropdown submenus.

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.