Tips for adjusting the text alignment within a button among multiple elements using CSS

I am currently working with this HTML code in Vue.js:

 <div class="confirm-button">
    <button v-on:click="placeOrder" v-bind:disabled="!buttonEnabled">
      <h1>Order</h1>
      <i class="far fa-spinner fa-spin" v-show="!placeOrderLoading"></i>
    </button>
 </div>

Here is the CSS file related to the above HTML snippet. The 'fa-spin' icon appears based on the "v-show" property. However, when the 'fa-spin' appears, the 'h1 - Order' text shifts left in order to stay centered with the 'fa-spin'. My intention is to keep the position of the 'h1 - Order' text fixed at the center while only positioning the 'fa-spin' icon to the right without affecting the 'h1-order' text. Can you provide some suggestions or advice on how to achieve this? Thank you for taking the time to read through my query.

.confirm-button button {
  box-sizing: border-box;
  width: 100%;
  height: 80px;
}
.confirm-button h1 {
  display: inline;
  font-size: 18px;
}
.confirm-button .fa-spin {
}

Answer №1

Hopefully, this solution will be of assistance to you.

.confirm-button button {
  box-sizing: border-box;
  width: 100%;
  height: 80px;
  position: relative; /* newly included */
}
.confirm-button h1 {
  display: inline;
  font-size: 18px;
}
.confirm-button .fa-spin {
  position: absolute; /* newly added */
  right: 15px; /* newly included*/
}

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

Displaying an element as a dropdown menu on PrimeVue

I have a challenge with rendering a Dropdown using PrimeVue with the given script: <template lang="pug"> Dropdown#tag(v-model="tag" :options="tags") </template> <script setup> import axios from 'axios&a ...

The fixed background attachment breaks when using translateX(0)

I'm facing an issue with a scrolling element that has a fixed background: .my-element { background: url(/foo.png) no-repeat right bottom; background-attachment: fixed; } Everything works perfectly, until I apply a translate transform (even a sl ...

Upon loading, the Carousel is visible instead of being hidden, which is contrary to its intended behavior

Any help would be greatly appreciated as I am struggling with creating a web page featuring tabs for "London, New York, Shanghai". The initial page displayed is the "welcome" page with the other tabs hidden on load. I successfully implemented a carousel f ...

Creating a Search Functionality within a Tab Component in Ionic

I'm currently facing an issue with adding a search bar under the "Search" tab in my project. I've tried implementing similar logic to what's shown here, but it doesn't seem to function properly when using the ionic serve --lab live in-b ...

What is the best way to create an iframe positioned above a navigation bar using CSS?

When I click the button, an iframe pops up on my website. However, the navbar overlaps it unless I scroll down. You can view my practice site at: This is the issue I am facing: https://i.sstatic.net/TKmw7.png Oddly enough, everything looks fine when I ...

Using Django templates to include JavaScript files stored in the static directory

I'm facing an issue: within addWorkout.html: {% extends "workout/base.html" %} {% block footer %} <script type="text/javascript" src="{% static js/addWorkout.js %}"></script> {% endblock %} within base.html: {% load static %} <!DOCT ...

Modify the button input value within a PHP script

I am currently working on a piece of code that involves following different users and inserting values from a MySQL table. <td align="center"> <input type="button" name="<?php echo $id; ?>" id="<?php ech ...

Problems with Styling the Header Navigation

Currently facing two CSS challenges on techprosecurity.com that have been difficult to resolve. The header NAV menu displays a slight space when hovering over links that are not active, and I've searched for a solution without success. For instance: ...

React select and react modal cannot be overlaid on top of each other

I am facing an issue with my React modal that contains a react-select component. Some of the options at the bottom of the modal are not visible. How can I ensure that the select overlay appears on top of the modal to display all options? https://i.sstatic. ...

Ensuring Vue.js methods are correctly configured to handle Axios asynchronous requests

My Vue.js application fetches complex data from an API using Axios and then visualizes the data. Here is a snippet of my code: { data: () => ({ data: null, loading: false, errored: false, loadingMessage: '' }), methods: ...

Ensuring that the text-box is the same size as the image

I am encountering two challenges: When scaling the window down horizontally, I am facing an issue with aligning the images on the left (sideImage) vertically with the text box. I have attempted using margin-top auto and margin-bottom auto, but that doe ...

HTML - Centered layout with a constant header and footer

Imagine a layout where there is always a header at the top, a footer at the bottom, and the space between them should be filled by the content 100% (image 2). Additionally, everything in the header, content, and footer should be horizontally centered, usin ...

Is there a way to interact with a Bootstrap 5 dropdown in React without triggering it to close upon clicking?

I'm currently working on creating a slightly complex navigation bar using Bootstrap 5 and ReactJS. The issue I'm encountering involves the dropdown menu within the nav bar. Whenever I click inside the dropdown, even if it's just non-link te ...

The content div sits atop the full-width image instead of being displaced downwards

Featuring a stunning full-width image: .image { background-image: url(http://cdn1.tnwcdn.com/wp-content/blogs.dir/1/files/2014/06/wallpaper_51.jpg); background-position: center center; background-repeat: !important; position: absolute; ...

Creating an optical illusion using nested left borders in HTML and CSS for a captivating and repeating visual impact

I am looking to achieve a nested border-left effect on HTML lists where the left border moves in one step with each nested level: https://i.sstatic.net/QDS3d.png What I want is something similar to this with minimal gap between the listed term and bullet ...

creating a dictionary with headers and body using beautiful soup

I am currently in the process of scraping data from a website (example page) and my goal is to utilize headers as keys and the text below each header as the corresponding value. Here's a snippet of what I have implemented so far: import requests impor ...

JavaScript encountered a problem when trying to call the inline function

I created a function called controls that adds HTML elements dynamically into the specified div. function controls() { var block = $('#controls'); block.html(''); block.append('<button type="button" onClick="f ...

Tips for navigating an aframe scene on mobile devices

How can I enable scrolling over aframe on mobile devices? I attempted to disable the scene controls but scrolling still doesn't work; the scene keeps interacting instead. ...

Customize Bootstrap Navbar to Enable Horizontal Scrolling Specifically for Dropdown Buttons

Specific requirements: - Only buttons should be horizontally scrollable - Dropdown of buttons should appear just below the button without shifting the paragraph below Things I have attempted: - Tried using overflow:hidden/auto, overflow-x:auto, and pos ...

Identify the row containing a value of null using jQuery (functionality not performing as anticipated)

Whenever the user clicks on the GetData button, I retrieve JSON data and display it in an HTML table similar to the demo below. Demo: https://plnkr.co/edit/I4XYY6CZohf7IS6wP8dR?p=preview There are instances where the value can be null, such as the loanNu ...