Utilizing CSS3's flex concept to display two buttons on separate lines

Whenever I hover over a specific div element, two buttons appear side by side which is not the desired behavior. Below is the code snippet that I have used:

.main_div{
  width:160px;
  height:160px;
  border:thin black solid;
  padding:5px;
  position:relative;
  
  /* Firefox */
  display:-moz-box;
  -moz-box-orient:horizontal;
  -moz-box-pack:center;
  -moz-box-align:center;

/* Safari and Chrome */
  display:-webkit-box;
  -webkit-box-orient:horizontal;
  -webkit-box-pack:center;
  -webkit-box-align:center;

/* W3C */
  display:box;
  box-orient:horizontal;
  box-pack:center;
  box-align:center;

  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient:horizontal;

}

.main_div .hover_div{
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  width:100%;
  height:100%;
  background: rgba(0,0,0,0.5);
  display: none;
  
}

.main_div .hover_div .upload_btn{
background: white;
            padding: 3px 20px;
            color: #58666e;
            margin: 8px 0;
            
}

.main_div:hover .hover_div{
 /* Firefox */
  display:-moz-box;
  -moz-box-orient:horizontal;
  -moz-box-pack:center;
  -moz-box-align:center;

/* Safari and Chrome */
  display:-webkit-box;
  -webkit-box-orient:horizontal;
  -webkit-box-pack:center;
  -webkit-box-align:center;

/* W3C */
  display:box;
  box-orient:horizontal;
  box-pack:center;
  box-align:center;

  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient:horizontal;

}
<div class="main_div">
  <div class="hover_div">
  <div class="upload_btn cursor_pointer">
                                      <span>xyz</span>
                                    </div>
                                    
                                    <div class="upload_btn">
                                      <span>abc</span>
                                    </div>
  </div>
</div>

I am looking to vertically center the upload_btn with a gap of 10-12px between them.

Note: The solution should be compatible with IE10 while maintaining the same design.

Answer №1

.main_div{
  width:160px;
  height:160px;
  border:thin black solid;
  padding:5px;
  position:relative;
  
  /* Firefox */
  display:-moz-box;
  -moz-box-orient:horizontal;
  -moz-box-pack:center;
  -moz-box-align:center;

/* Safari and Chrome */
  display:-webkit-box;
  -webkit-box-orient:horizontal;
  -webkit-box-pack:center;
  -webkit-box-align:center;

/* W3C */
  display:box;
  box-orient:horizontal;
  box-pack:center;
  box-align:center;

  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient:horizontal;

}

.main_div .hover_div{
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  width:100%;
  height:100%;
  background: rgba(0,0,0,0.5);
  display: none;
  
}

.main_div .hover_div .upload_btn{
background: white;
            padding: 3px 20px;
            color: #58666e;
            margin: 8px 0;
            
}

.main_div:hover .hover_div{
 /* Firefox */
  display:-moz-box;
  -moz-box-orient:vertical;
  -moz-box-pack:center;
  -moz-box-align:center;

/* Safari and Chrome */
  display:-webkit-box;
  -webkit-box-orient:vertical;
  -webkit-box-pack:center;
  -webkit-box-align:center;

/* W3C */
  display:box;
  box-orient:vertical;
  box-pack:center;
  box-align:center;

  /* IE10 -Doesn't work yet! */
  display: -ms-flexbox;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -ms-box-orient:vertical;

}
<div class="main_div">
  <div class="hover_div">
  <div class="upload_btn cursor_pointer">
                                      <span>xyz</span>
                                    </div>
                                    
                                    <div class="upload_btn">
                                      <span>abc</span>
                                    </div>
  </div>
</div>

Update the value of the box-orient property from horizontal to vertical

Does this adjustment align with your requirements?

Trust this information proves useful.

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

Issue encountered while attempting to differentiate '[object Object]'. Solely arrays and iterables are permitted. (Ionic version 3)

I'm currently working on a project and encountering the error message Error trying to diff '[object Object]'. Only arrays and iterables are allowed. After researching, I found two potential solutions - adjusting the incoming data (which is n ...

A challenge in web design: tackling cross-browser color discrepancies

I have implemented CSS code in an HTML page to define the color values of H1 and H2 elements. <style type="text/css"> img {border-style: none;} H1 {color: "#33CCFF"} H2 {color: "#33CCFF"} </style> While this setup works well on Internet Explo ...

Is there a way to create a navigation menu that highlights as we scroll down the page?

Check out this example of what I am looking for. https://i.stack.imgur.com/fdzvZ.png If you scroll, you will notice that the left menu highlights. Sub-menus will extend when the corresponding menu is highlighted and collapse when other menus are highlig ...

Submit your information discreetly

Is there a way to submit a form to an external website without it causing the page to reload? I am working on automatically logging users into their Google account without interrupting their browsing experience. The following code snippet allows me to pr ...

Tips for providing a link to a label and passing a query string to a different page in ASP.NET using C#

I am working on an asp.net page with SQL Server 2008 as the database. I have created three stored procedures; one to count the total number of users in tbl_users, another for counting the total male users, and the last one for counting the total female use ...

Seeking a jQuery Carousel with a Blizzard-inspired design

Can anyone recommend a jQuery carousel that has similar features to the one found on Blizzard's homepage? I'm looking for a carousel that is centered, does not show horizontal scroll bars even if the content extends beyond the browser width, supp ...

Is there a way to ensure that the header is centered at the top and the footer is centered at the bottom of every printed page, even when

Currently, I am utilizing spatie/browsershot to generate PDF documents within a Laravel project. While it offers convenient methods such as headerHtml and footerHtml for customization, there seems to be an issue with handling images. Specifically, only bas ...

Tips on replacing a React component's styling with emotion CSS

Is there a way to incorporate the background-color:green style to the <Test/> component in the following example without directly modifying the <Test/> component? /** @jsx jsx */ import { css, jsx } from "@emotion/core"; import React from "r ...

I am having trouble compiling sass in VS Code using the sass --watch command

I've encountered an issue while trying to compile sass through the terminal. Despite having already installed node.js and successfully using Live Sass, I consistently receive the following error message: sass : The term 'sass' is not recogni ...

A guide on automating the html5 color picker using input type="color" in selenium webdriver

When interacting with an HTML color input element, a color picker window pops up that prevents viewing the DOM. I am looking for a solution to either select a color and close the window or enter a hex code in the popup's text box. Can anyone provide m ...

Deactivating The Canvas Element

I am currently working on a project that involves using Three.js alongside a menu placed above the canvas element, which is essentially a regular div. However, I have encountered an issue where the canvas element still registers input when interacting with ...

Obtaining the calculated background style on Firefox

Back when my userscript was only functional on Chrome, I had a setup where I could copy the entire background (which could be anything from an image to a color) from one element to another. This is how it looked: $(target).css('background', $(so ...

Struggling to align the image elements accurately

I am aiming to create a layout similar to the image displayed below.https://i.sstatic.net/Q5n8J.png To be more specific, my goal is to scatter smiley faces randomly within a 500px area while also having a border on the right side of the area. However, wi ...

Steps for creating a hyperlink that exclusively opens in Chrome and includes a disable flag

I am looking to create a hyperlink that will launch chrome with the flag --disable-hang-monitor, followed by opening the website https:\\randomwebsite.com. Here is the location for Google Chrome: c:\program Files(x86)\Google\Chrom ...

Determining the width of an element in terms of percentage

My issue involves input elements with widths set as percentages in CSS under the common class 'display-class' For example: input.test1 { width: 60% } In JavaScript, I am attempting to wrap a div around these input fields with the same width ...

How to apply new CSS styles to override the existing ones for an element

I have a website with custom CSS styling applied to an <A> tag, including styles for A:hover. However, I need to remove these hover effects for one specific instance of the tag. Is there a way in CSS to set a property so that it does not change? Let ...

AngularJS bidirectional binding with numerous select choices

I am faced with a unique challenge - I have a list of non-exclusive fields that users want to see presented in a select box allowing multiple selections, rather than individual checkboxes bound to Boolean values in the model. While I know how to create t ...

Struggling to locate an element with Selenium and Python?

I'm a newcomer to Python/Selenium and I've spent hours searching and thinking about my issue. My task is to extract a specific value from an element on the ticket creation website we use at work. The problem is, the element containing the ticket ...

Is it possible to utilize the base-tag in order to transmit parameters?

I have implemented a custom debugging feature within a large framework where by adding ?debug to any URL, I am able to access specific server data. However, the issue arises when clicking on a link as the ?debug parameter disappears. Is there a way to reta ...

Tips for utilizing the JQuery feature to clear input text

After attempting to use onfocus and onblur attributes within the input tag to clear input text, I discovered a JQuery function that should do the trick for me. However, I am encountering issues with getting it to work across multiple fields. $('.defa ...