How can you align a button in the center relative to another button positioned above it?

I am having trouble centering a button in relation to the button above it. The image shows that the lower button is not properly centered.

I attempted to fix this issue by using the following CSS:

.btn {
  padding: 16px 22px;
  color: #fff;
  border-radius: 4px;
  position: relative;
  -webkit-transition: all .3s linear;
  -moz-transition: all .3s linear;
  -ms-transition: all .3s linear;
  -o-transition: all .3s linear;
  transition: all .3s linear;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 2px 5px 0 rgba(0, 0, 0, 0.15);
  border: none;
  text-transform: uppercase;
}

.btn-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-common {
  background: #3498db;
}

.btn-xs {
  border-radius: 0px;
  font-size: 12px;
  line-height: 1.5;
  padding: 1px 5px;
}
https://i.sstatic.net/ZXnaZ.png

Answer №1

To successfully align the elements, ensure that you set a specific width for pull-right and apply margin: auto to the btn-center. This will make the wrapper adjust accordingly to fit the elements.

Link to example code on jsFiddle

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

How can a material progress spinner be inserted into the Angular Ag-Grid overlayNoRowsTemplate?

I'm attempting to include a mat-progress-spinner within my agGrid when there are no rows to display. Here's an example that works: private overlayNoRowsTemplate = '<p>No rows to show.</p>'; However, when I attempt to add ...

make the chosen text appear on Internet Explorer

1 How to insert text into a text box using code? 2 Moving the caret to the end of the text. 3 Ensuring the caret is visible by scrolling the text box content. 4 Programmatically selecting specific text in a textbox. 5 **How to make selected text visible?** ...

Personalizing the structure of a joomla template

Having some trouble customizing my Helix Framework template. I'm trying to adjust the width of the page to be 1140 px. When I make changes in the framework menu, it only adjusts the text field width and not the graphics. How can I achieve the layout s ...

Read a local file using the HTML5 FileReader

I am currently working on developing an offline application that can read text from a locally stored text file. I have been researching and found that using html5 and FileReader can make this possible. My goal is to set a hard-coded relative path for the ...

What could be causing the disappearance of the border around this `<li>` element?

I am currently redesigning the Kotaku website and facing difficulties in creating a list for the footer. Below is an image illustrating my issue. The 'Popular tags' section has been created using the <ul> and <li> elements, with an & ...

HTML5 - the enigmatic header and outline procedure

While revisiting the HTML5 spec, I came across a question about nesting a nav element within a header. The description for the header element seemed a bit peculiar to me, mainly because I couldn't fully grasp it. In the given example, the page inc ...

Turn off interpolation during the scaling of a <canvas> tag

Important: The issue at hand pertains to the rendering of existing canvas elements when scaled up, rather than how lines or graphics are rendered onto a canvas surface. In simpler terms, this revolves around the interpolation of scaled elements, not the an ...

Passing a JavaScript variable through a URL link

I need to pass a JavaScript variable to a specific webpage. Here is the code I am using: <script> function hello() { var data="hello"; <a href="www.mytestsite.com?var="' +data +'>Send now</a> } </script> The hello() func ...

What is the method to retrieve the color of a linearGradient in an SVG at a particular

I am working on a unique progress bar that uses a linear gradient and a small ellipse to indicate the completion percentage. The AngularJS binding updates the completion percentage and a function is called. My challenge is to change the color of the ellip ...

Having trouble with the Image Path not connecting from the backend to the frontend of my application

I have been working on getting photos from my backend server and displaying them on my website. The images are stored in the API with a path that looks like localhost:44333/Images/[imagename]. On the frontend, I have tried adding the path dynamically, as ...

.htaccess keeps track of login information

Similar Query: HTTP authentication logout via PHP I have set up my website to protect a specific folder using .htaccess and .htpasswd. Initially, the login prompt works as expected and requires me to enter my credentials to access the protected conten ...

If all input values within every li element are equal to zero in jQuery

Currently, I am facing an issue that I need to solve. I have multiple inputs and my goal is to check if each input has a value of 0 and is also checked. After spending an entire day searching for a solution, I am still clueless about how to proceed. I att ...

I am unable to insert an HTML horizontal rule

Currently, I am attempting to separate the sections in my tablet, but I am facing difficulty adding a dividing line. When I try to add style = "border: 1px solid black" in the tr section, it shows up but not in the desired manner. The code snippet is as f ...

How CSS properties can cause one div to push down another

I am looking to incorporate a simple sidebar into an existing layout (content). Here is what I have so far: HTML <div class="container"> <div class="side-menui"> </div> .... </div> Full HTML <div class="c ...

A CSS rule to display a nested list on the left-hand side

I created a menu that you can view here. When hovering over "tanfa demo example," the sublist appears on the right side. The issue I'm facing is that my menu is positioned all the way to the right, which means the sublist also appears on the extreme ...

Displaying an image gradually as the user moves down the page

Recently, I came across this fascinating website: As you scroll down, the images on the site gradually unveil more details, which caught my attention. This unique effect is not something commonly seen on websites, and I'm curious to learn how it is ...

Position a div element after another using the :after pseudo-element

My goal is simple to explain, but I have exhausted all my efforts trying to achieve it. I am hoping for the ★ symbol to appear immediately after the number 06 using jQuery. Any assistance would be greatly appreciated. The numbers are generated by a s ...

Is it possible to utilize :not in this scenario?

<ul class="promocode"> <li>one</li> <li>two</li> <li class="three">three</li> </ul> Is there a way to use :not in order to apply a hover effect to the entire list, except when hovering ov ...

What is the method for setting a video as the background of my div?

I've been trying to set a Youtube video as the background of my div. After researching online, I found that many people followed these steps: Welcome Easy to use. S ...

Using a Chrome Extension to interact with the DOM of the popup.html page and successfully implementing jQuery functionality

As a novice in the realm of Chrome Extension development, I am currently facing two challenging obstacles: The first hurdle is accessing the DOM of my popup.html file, the foundation of my extension. I've attempted various methods including inline ...