Problem with holding a dropdown button

Having trouble maintaining the position of this button within the floating button holder above my website content. How can I incorporate a drop-down menu while ensuring it stays within the same button holder?

.btn-holder {
        background: rgba(255, 255, 255, 0.5);
        position: static;
        z-index: 10;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
      }
      .button {
        transform: translate(-50%, -50%);
        background-color: #a137a7;
        border: none;
        color: white;
        padding: 8px 13px;
        text-align: center;
        text-decoration: none;
        font-size: 16px;
        position: absolute;
        cursor: pointer;
        right: -1%;
        bottom: -1%;
        font-family:'Source Sans Pro', sans-serif;
        opacity: .8; 
      }

      .button:hover {
        background-color: #732878;
        color: white;
      }
<div class="btn-holder">
        <div class="button"><a href="/"><img class="img-responsive2" src="http://static.tumblr.com/e2rgcy1/e6Yod1iwo/pop-out-icon.png"></a></div>
      </div>

      <!-- begin snippet: js hide: false console: true babel: false -->

Answer №1

Need a starting point for your menu design? Here's a quick example to steer you in the right direction! There are some potential improvements to consider, like delaying the display:none to allow clicking on menu links. If you need further assistance, just drop a comment and I'll be happy to help.

#btn-holder {
  background: rgba(255, 255, 255, 0.5);
  position: static;
  z-index: 10;
  bottom: 0;
  right: 0;
  left: 0;
  top: 0;
}

#btn-holder > .button {
  transform: translate(-50%, -50%);
  background-color: #a137a7;
  border: none;
  color: white;
  padding: 8px 13px;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  position: absolute;
  cursor: pointer;
  right: -1%;
  bottom: -1%;
  font-family: 'Source Sans Pro', sans-serif;
  opacity: .8;
  border-radius: 3px;
}

#btn-holder > .button:hover {
  background-color: #732878;
  color: white;
}

#btn-holder > .menu {
  opacity: 0;
  transition: opacity .5s;
  width: 100px;
  transform: translate(-50%, -50%);
  background-color: #333;
  border: none;
  color: white;
  padding: 8px;
  text-align: left;
  text-decoration: none;
  font-size: 16px;
  position: absolute;
  right: 100%;
  bottom: 25px;
  box-shadow:0 2px 7px rgba(0,0,0,.4);
}

.menu a {
  text-decoration: none;
  color: #eee;
  transition: color .3s;
}

.menu a:hover {
  color: #2196f3;
}

.menu > ul {
  list-style: none;
  margin: 2px;
  padding: 0 0 0 15px;
}

.menu > ul > li:first-child {
  margin-left: -15px;
}

.menu p {
  opacity: 1;
  margin: 0;
}

.menu p:after {
    content:"";
    display: block;
    height: 1px;
    vertical-align: bottom;
    width: 100%;
    border-top: 1px solid #eee;
    opacity: .4;
}

#btn-holder > .button:hover + .menu {
  opacity: 1;
  transistion-delay: 1s;
}

#btn-holder .menu:hover {
  opacity: 1;
}
<div id="btn-holder">
  <div class="button">
    <a href="/"><img class="img-responsive2" src="https://static.tumblr.com/e2rgcy1/e6Yod1iwo/pop-out-icon.png"></a>
  </div>
  <div class="menu">
    <p><a href="#">Home</a></p>
    <ul>
      <li><a href="#">Blog</a></li>
      <li><a href="#">Post 1</a></li>
      <li><a href="#">Post 2</a></li>
    </ul>
    <p><a href="#">Products</a></p>
    <p><a href="#">About</a></p>
  </div>
</div>

For hands-on experimentation, check out the codepen link where you can make your own tweaks: http://codepen.io/XanderLuciano/pen/YGPoqE

To reveal the menu when hovering over the button using CSS, I utilized the + selector. When .button:hover is activated, the adjacent div class="menu" changes from display:none to block. Here's an excerpt of the code:

#btn-holder > .button:hover + .menu {
  display: block;
}

If you need clarification or have any questions, feel free to reach out! :)

Answer №2

#btn-holder {
  background: rgba(255, 255, 255, 0.5);
  position: static;
  z-index: 10;
  bottom: 0;
  right: 0;
  left: 0;
  top: 0;
}

#btn-holder > .button {
  transform: translate(-50%, -50%);
  background-color: #a137a7;
  border: none;
  color: white;
  padding: 8px 13px;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  position: absolute;
  cursor: pointer;
  right: -1%;
  bottom: -1%;
  font-family: 'Source Sans Pro', sans-serif;
  opacity: .8;
  border-radius: 3px;
}

#btn-holder > .button:hover {
  background-color: #732878;
  color: white;
}

#btn-holder > .menu {
  opacity: 0;
  transition: opacity .5s;
  width: 100px;
  transform: translate(-50%, -50%);
  background-color: #333;
  border: none;
  color: white;
  padding: 8px;
  text-align: left;
  text-decoration: none;
  font-size: 16px;
  position: absolute;
  right: 0%;
  bottom: 25px;
  box-shadow:0 2px 7px rgba(0,0,0,.4);
}

.menu a {
  text-decoration: none;
  color: #eee;
  transition: color .3s;
}

.menu a:hover {
  color: #2196f3;
}

.menu > ul {
  list-style: none;
  margin: 2px;
  padding: 0 0 0 15px;
}

.menu > ul > li:first-child {
  margin-left: -15px;
}

.menu p {
  opacity: 1;
  margin: 0;
}

.menu p:after {
    content:"";
    display: block;
    height: 1px;
    vertical-align: bottom;
    width: 100%;
    border-top: 1px solid #eee;
    opacity: .4;
}

#btn-holder > .button:hover + .menu {
  opacity: 1;
  transistion-delay: 1s;
}

#btn-holder .menu:hover {
  opacity: 1;
}
<div id="btn-holder">
  <div class="button">
    <a href="/"><img class="img-responsive2" src="https://static.tumblr.com/e2rgcy1/e6Yod1iwo/pop-out-icon.png"></a>
  </div>
  <div class="menu">
    <p><a href="#">Home</a></p>
    <ul>
      <li><a href="#">Blog</a></li>
      <li><a href="#">Post 1</a></li>
      <li><a href="#">Post 2</a></li>
    </ul>
    <p><a href="#">Products</a></p>
    <p><a href="#">About</a></p>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Scrolling horizontally to display dynamic columns based on a search query in AngularJS

I am facing a challenge with implementing search functionality in a table that has multiple dynamic columns with a horizontal scrollbar. The goal is for users to be able to search for a specific column name or data, and if a match is found, the scrollbar s ...

css optimizing image content for search engine visibility

My website's main page features a div with an image containing the message "contact us by calling 1 800 blabla..". I'm concerned that search engines may not be able to recognize or find my company's phone number since it is only displayed wi ...

The iteration count and stop code in CSS are failing to function correctly

Is there a way to make this loop once and then stay as is unless the page is refreshed? I've tried multiple methods I came across. Can you modify the code so I can see where the changes are being made? The goal is to have it display once and then per ...

What is the best way to implement horizontal content scrolling when an arrow is tapped in mobile view?

I recently created a JS Fiddle that seems to be working fine on desktop, but in mobile view, the square boxes have horizontal scrolling. Here are the CSS codes I used for this particular issue: @media only screen and (max-width: 767px) { .product-all-con ...

Alert popup onclick feature is malfunctioning

SOLVED: I finally figured out the issue and it is now working perfectly. I had to manually switch to Chrome instead of using the Brackets live viewer. I want an alert box to pop up when the "Home" link is clicked on my website. I tried creating a separate ...

Steps to insert a new row for a grid item using material-ui

When it comes to breaking a line of grid item like this, the image shown below illustrates how the rest space of the grid should be empty. https://i.stack.imgur.com/pvSwo.png <Grid container spacing={3} <Grid item xs={12}> "Grid Item xs ...

"Troubleshooting issue in Django 1.6.2 where CSS styles are not being applied to

I am encountering an issue with this code and would greatly appreciate some assistance. The base.html file contains a {% block content %}{% endblock %}. I have created a Signup.html file structured like this: {%extends 'base.html'%} {% block co ...

Ensure that the content fills the entire height of the container and include a scrollbar

I'm currently utilizing CKEditor () and have developed my own customized file browser. The issue I'm encountering is that when the filebrowser is opened, it appears in a new popup window without scrollbars. I reached out for support through a ti ...

What could be causing the lack of animation in W3schools icons?

I've followed the steps provided and even attempted to copy and paste them. However, I'm experiencing an issue where the animation doesn't fully execute. Instead of the bars turning into an X shape, they reset halfway through the animation. ...

Scrolling with Jquery window.scrollTo results in the page becoming unresponsive

I'm currently revamping a website that features a header with 100% screen height, but I need it to shrink down to 0px when a user starts scrolling. The issue I'm facing is that once the header shrinks to 0px, the page content ends up slightly abo ...

Switch the style sheets after the content

How can I create a toggle effect on the :after property, switching between + and - each time the link is clicked? I've attempted to achieve this using JavaScript, CSS, and HTML, but the code only changes + to - and doesn't switch back when the l ...

Guide to navigating to a different webpage with Node.js

I am a beginner user of NodeJS and I have a specific request. I need assistance with setting up a page redirect from one page to another upon clicking on a link. Any guidance provided will be greatly appreciated. Here is the code snippet: app.js var expr ...

"Dragging and dropping may not always perfectly align with the position of the droppable div that is

When attempting to drag and drop three images into a droppable div, I encountered an issue where the images were not perfectly positioned within the div. This problem seemed to be related to the positioning of the droppable div itself. Specifically, when s ...

Navigate divs with varying z-index values

I want to change the z-index of 3 divs by toggling them using jQuery, but I'm not sure how to do it. What I want is to click a button that relates to a specific div and increase the z-index of that div so the content inside it is shown. Currently, all ...

Can a single character within a span be located and customized using only CSS techniques?

My inquisitive mind believes that the answer lies in the negative, however, CSS3 pseudo-selectors have the ability to work their magic almost like performing illusions on a stage. In an absurd context, I am determined to locate and style the period charac ...

Following the modification of the Context root, the JSP page is no longer functioning as expected

Recently, I developed a JSP page within the webapp that utilizes jquery, CSS, and Angular JS. The files jquery-1.12.0.js, angular.min.js, and TableCSSCode.css are all located in the same directory as the JSP page. Initially, my application context was set ...

How can I resolve the issue with the HTML/CSS footer not functioning properly on Safari for iPhone in my mobile site?

Struggling with a mobile website issue here. The client wants text-based buttons/links at the bottom, so I added them in, but my skills with size percentages are a bit rusty. I need these buttons to line up horizontally and adjust their width accordingly ...

Dynamic resizing in NextJs does not trigger a re-render

My goal is to dynamically pass the width value to a component's styles. Everything works fine on initial load, but when I resize the window, the component fails to re-render even though the hook is functioning as intended. I came across some informat ...

Resolve the issue of Dojo images not appearing on a div in Internet Explorer

I am trying to incorporate images into a dojo chart using the given code: var l_images = ["images/clearnight.png","images/clear.png","images/partlyCloudy.png","images/cloudy.png","images/showers.png","images/rain.png","images/thunderstorms.png","images/ic ...

Can you explain the distinction between using a period in a class selector and not using one?

Could someone please clarify the meaning of the code snippet below? <div class="cls1 cls2">abcd <div class="cls2"> adfffff </div> </div> .cls1 { background-color: yellow; } /*sample1 .cls1.cls2 { color: red; } */ /* ...