Position a fidget spinner in the middle of a button

I'm currently working on centering a spinner inside a button. The purpose of the spinner is to indicate that the system is processing a response. Despite my efforts to adjust margins and padding in the code, the spinner remains at the bottom of the button without moving up as intended.

Below is the Jade code I am using:

div.form-group
    div.col-sm-4
        button.form-control.btn.btn-success.strong-button(type='submit' ng-model='pressed' ng-disabled="pressed") Delete
            spinner(ng-show="submitDelete")

The CSS styling for the spinner is as follows:

.font-awesome-spinner{
    width: 100%;
    text-align: center;
}

A snippet from the page source shows how the spinner element creates a div inside the button element:

<button (all the stuff here)>
     <div class="font-awesome-spinner ng-isolate-scope" ng-show="submitDelete">
          <i class="fa fa-circle-o-notch fa-spin"
               ::before
          </i>
     </div>
</button>

Answer №1

To center a block element like a DIV, do not use text-align: center;. Instead, set the width of your spinner div and apply margin: auto; to achieve center alignment.

Furthermore, your HTML code is incorrect. Take a look at (all the stuff here) within your button element.

<!DOCTYPE html>
<head>
  <style type="text/css">
    #button_element {
      width: 100px;
    }
    #button_element .font-awesome-spinner {
      width: 50px;
      margin: auto;
    }
  </style>
</head>
<body>
  <button id="button_element">
    <div class="font-awesome-spinner ng-isolate-scope" ng-show="submitDelete">
      <i class="fa fa-circle-o-notch fa-spin"></i>
    </div>
  </button>
</body>
</html>

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

Vue component updating its model only upon input element losing focus

I'm a beginner with vue and I'm currently working on incorporating an ajax search feature that triggers when a keyup event occurs. I have noticed that the model only updates when the input element loses focus. Sample HTML Code: <input name=" ...

The website created with Mobirise's HTML is experiencing display issues after being uploaded to NGINX through PuTTY

Recently, I embarked on building a website using NGINX but realized it needed a major revamp. That's when I turned to Mobirise as my HTML expertise is limited. Here's the initial site I created: https://i.stack.imgur.com/IsCg4.jpg However, upon ...

How can I position the hyperlink inline with the font-awesome Icon?

Hey everyone, I'm having some trouble creating a top info bar in Bootstrap 4.1.3 with Font-awesome 5.5. I want to include essential details like phone number, email address, and social icons, but whenever I try to add a hyperlink after the icon, it dr ...

Ensure that the child element stays within the parent container by using the max-top property for relative

Check out this HTML code snippet: https://jsfiddle.net/1t68bfex/ button { position: relative; top: 100px; left: 150px; max-top: 10px; } .third-party-block { //display: none; } <div style="border:1px solid red;"> <button> ...

The anchor tag causes the tooltip to display outside of the td element

One of my requirements is to display the click percentage for each link in an HTML template that is dynamically fetched from a database. I attempted to show the click percentage for each anchor link by adding them to the `data-title` attribute using jQuery ...

CSRF validation did not pass. The request has been cancelled. The failure occurred due to either a missing or incorrect CSRF token

Upon hitting the submit button in the login form, I encountered the following error message: Forbidden (403) CSRF verification failed. Request aborted. CSRF token missing or incorrect. settings.py MIDDLEWARE = [ 'django.middleware.security.Secur ...

Obtain the value of the nth child in jQuery without referencing the HTML tag

I need to work with the number 1.99 in my calculations, but it is preceded by a dollar sign which is subject to change. $(function() { const x = $('#test').text(); console.log(x); console.log(Number(x) + Number(x)); }); <script src="https://cd ...

What is the reason behind the decision to have the writable section of the form begin in the center?

Hey everyone, I recently attempted to create a form for the first time but ran into an issue with the writable area not starting at the beginning. I suspect it has something to do with the padding, but being new to this environment, I'm having trouble ...

What is the process for applying cdkDropList to the tbody when using mat-table instead of a traditional HTML table?

I have been experimenting with the mat-table component in my Angular project, following a simple example from the documentation: <table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <!--- These columns can be ...

Is it possible to have 2 images side by side?

I am attempting to combine these two images to create a map. Here is an illustration of how they should fit together. https://i.sstatic.net/zGZgS.png var testHeightMap = 'x\n' + 'x'; var myCanvas = document.getElementById( ...

Pressing the enter key should trigger jQuery to submit the form

Whenever a user submits a comment on my site by pressing enter, it works as intended. However, if the user wants to create a new line without submitting the comment (e.g., by pressing shift+enter), how can this be achieved? This is the current code I have ...

Is it possible to trigger an A-Frame DOM/CSS/animation event based on video timestamps?

Is it possible to activate an event in A-Frame based on a specific time point of a video or audio file, without the need to interact with the video object directly? For example, changing the light or color properties of a nearby primitive? I am currently ...

Attempting to align the dropdown menu to the left side

This is a challenge I'm facing: https://i.sstatic.net/d3PtN.png I'm attempting to align it in the following way: https://i.sstatic.net/GCwEO.png Below is the HTML code snippet: <li class='list-group-item'> <!-- The dropdow ...

Error: Unable to locate or read the file "style.scss" for import

I'm currently in the process of setting up a new vuejs project from scratch, but I've encountered an error when trying to import "style.scss" into my component. Specifically, the issue arises in the Login.vue file where I include the style.scss. ...

Updating a table in Javascript after deleting a specific row

Is there a way to automatically reindex rows in a table after deleting a row? For example, if I delete row 1, can the remaining rows be reordered so that they are numbered sequentially? function reindexRows(tableID) { try { var t ...

The division is refusing to make an appearance

As I embark on creating my very first website, I'm encountering some obstacles in translating my vision into reality. The #invokeryolo div is proving to be elusive and no matter how hard I try, I can't seem to make it appear on the screen. Below ...

Restricting the height of a column in Bootstrap 4 to create a more compact design

Currently, I have an element that contains a few columns. The issue is that all columns end up being the same height as the tallest one. What I want is to set a minimum height for one specific column, #colB, and have the other two columns scroll vertically ...

What is the best way to selectively import specific data from an HTML table into R?

Currently I am working on importing a table from a website to R for my homework assignment. The specific website I am referring to is . I attempted the following code, which seemed fine at first, but it included the description part under the variable "Ins ...

Shift a div towards the right edge of the navigation bar

**I am looking to reposition the Navbar_icon div to be on the right side of the navbar. The Navbar_icon contains icons for search, help, and sign in. ** Current layout of the navbar is shown in the image below: <https://i.sstatic.net/GGvBa.png> REA ...

The necessity of using Adobe Photoshop for optimizing a Web Template

My interest lies in utilizing web templates, such as the one referenced here:- templete However, within its details tab, it specifies that the following software is required:- Adobe Photoshop CS+ Sublime Text2 or later, Notepad++, Dreamweaver CS5.5+(Co ...