Struggling to align text input within a label element

I'm struggling with centering the text on Bootstrap radio buttons that I am customizing. I have tried adjusting the margin, align-content, vertical-align, and text-align properties but the text still won't vertically center. Any suggestions?

Here's the HTML:

<div class="root">
    <div class="btn-group" data-toggle="buttons">
        <label class="btn btn-default active form-check-label">
            <input class="form-check-input" type="radio" checked autocomplete="off"> One
        </label>

        <label class="btn btn-default form-check-label">
            <input class="form-check-input" type="radio" autocomplete="off"> Two
        </label>

        <label class="btn btn-default form-check-label">
            <input class="form-check-input" type="radio" autocomplete="off"> Three
        </label>
    </div>
</div>

Here's the CSS:

@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');

.root .btn-group .btn {
    border-radius: 0;
    border-color: black;
    background-color: white;
    color: black;
    box-shadow: none;
    min-width: 90px;
    height: 45px;
    align-content: center !important;
    vertical-align: middle !important;
    text-align: center;
}

.root .btn-group .btn .form-check-input {
    text-align: center;
    vertical-align: middle;
    margin: 0px;
}

.root .btn-group .btn.active {
    background-color: black;
    color: white;
}

Answer №1

Below are the styles to be added on label:

display: flex;
align-items: center;
justify-content: center;

 


.root .btn-group .btn {
border-radius: 0;
border-color: black;
background-color: white;
color: black;
box-shadow: none;
min-width: 90px;
height: 45px;
align-content: center !important;
vertical-align: middle !important;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
}

.root .btn-group .btn .form-check-input {
text-align: center;
vertical-align: middle;
margin: 0px;
}

.root .btn-group .btn.active {
background-color: black;
color: white;
}
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<div class="root">
<div class="btn-group" data-toggle="buttons">
    <label class="btn btn-default active form-check-label">
        <input class="form-check-input" type="radio" checked autocomplete="off"> One
    </label>

    <label class="btn btn-default form-check-label">
        <input class="form-check-input" type="radio" autocomplete="off"> Two
    </label>

    <label class="btn btn-default form-check-label">
        <input class="form-check-input" type="radio" autocomplete="off"> Three
    </label>
</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

Arranging several lists in columns with a customized header title

I am looking to have 7 lists displayed side by side, each with a unique styled header title. I want the lists to be neatly organized under their respective titles, including the bullets. I attempted to use text-indent for this purpose, but it seems that ...

How to arrange table data in Angular based on th values?

I need to organize data in a table using <th> tags for alignment purposes. Currently, I am utilizing the ng-zorro table, but standard HTML tags can also be used. The data obtained from the server (via C# web API) is structured like this: [ { ...

Sharing a collection of data fields

I am dealing with dynamic fields within a Bootstrap three form that is divided into tabs. Due to the removal of form tags in the modal, I have my fields set up outside. I can successfully post the values using jQuery attribute selectors like $("input[name ...

Troubleshooting Paths with Angular's NgFor Directive

Within my Angular project, I have implemented a basic ngFor loop to display logo images. Here is a snippet of the code: <div *ngFor="let item of list" class="logo-wrapper"> <div class="customer-logo"> & ...

What is the way to retrieve an array property in a typescript interface?

Imagine a scenario with three interfaces structured as follows: registration-pivot.ts export interface RegistrationPivot { THead: RegistrationPivotRow; TBody: RegistrationPivotRow[]; } registration-pivot-row.ts export interface RegistrationPivotR ...

Adjustments to the positioning of masonry columns

Hello everyone, I'm in need of some assistance with editing this code. My goal is to make the effect clickable rather than activated by hovering. You can view the current code snippet here. Here is the existing code: $container.find('.shifty-i ...

JavaScript functions smoothly on Google Chrome but is restricted on Internet Explorer

Experimenting with the code found on this website to conduct some testing. The javascript functions smoothly in Google Chrome and Firefox, but encounters issues in IE. Interestingly, when I run the html file in IE locally, it does work, but a warning pops ...

Tips for concealing the currently playing track title on a media player

I'm looking for a way to conceal the track title displayed in the media player on Internet Explorer. Here's the code I currently have: <object id="mediaPlayer" width="320" height="240" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type ...

Verify if data already exists in an HTML table column using JavaScript

As a beginner in web programming, I am currently trying to dynamically add data to a table. But before inserting the data into the table, my requirement is to first verify if the data already exists in a specific column, such as the name column. function ...

What is the best method for uploading photos via ajax in a django application?

Currently, I am in the process of creating a function that allows users to update their profiles by changing their email addresses, names, and profile pictures. While I have been successful in updating emails and names, I have encountered difficulties in u ...

Is it possible to comment out classes within a specified class attribute? How can this be achieved?

Is there a way to temporarily omit specific classes within HTML (<div class="" ...>)? For instance: <div data-group="group1" data-container="true" class="container-lg d-flex /* slider */ p-0"> In this s ...

Hide the search results if the user leaves the input field blank

I am trying to implement Live Search JSON Data Using Ajax jQuery, and I want to be able to search through multiple JSON files. When the page initially loads with an empty input field, no results are displayed. However, if you type and then delete text in ...

The <a> tag does not have the clickability feature

My personal website doesn't allow me to click on the links that I have added for web pages. Here is the CSS code I am using: @font-face { font-family: typewrite; src: url(fonts/typewcond_regular.otf); } @font-face { font-family: typewrite; sr ...

Steps to align the table to the left with the header

I created a webpage that includes a header and a table at this link Can anyone help me align the left border of the table with the left border of the header image? I'm not sure how to do it. Appreciate any assistance! ...

How can elements be displayed differently depending on the return value of a function?

Basically, I am looking to display different content based on the status of a job: Show 'Something1' when the job is not processing Show 'Something2' when the job is running and has a status of '0' Show 'Something3&apos ...

"Can you provide instructions on placing a span within an image

I am trying to figure out how to insert a <span> into an <image>, similar to the effect on the page . However, I do not want this effect to occur on hover(), but rather on click(). My goal is to insert "data-title" into the <span> and hav ...

Some characters are not compatible with the CSS writing-mode feature

There seems to be an issue with the CSS writing mode not applying correctly to the symbol '№'. Here is an example: <html> <head></head> <body> <p style="writing-mode: vertical-lr;"> Номер № ...

Display a dynamic variable within React's HTML code

const fetchTime = () => { const currentDate = new Date(); const currentTime = currentDate + ' ' + currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds(); return {currentTime}; } export default fun ...

Leverage CSS to generate a visually appealing table of contents incorporating images and text blocks, perfectly aligned for an enhanced

I am in the process of designing a unique clip showcase on my website. The concept involves creating a table-like structure with a thumbnail image on the left and various information on the right, including a title, publication source, date, and descriptio ...

Adjusting the transparency of the background without altering its colors

I need help figuring out how to merge custom palettes I've created such as this one, which resulted in a .css and .less file. While I want to retain the colors, I also require certain elements' backgrounds to be transparent. To achieve this, I c ...