Centered label above an inline input form

I'm struggling with aligning inputs under long labels in a form. I want the input fields centered under each label while keeping them inline. The desired look is shown below:

https://i.sstatic.net/itJCY.png

The current code I have is not achieving the desired center alignment under the labels.

.question-container {
  width: 1000px;
  margin: 0 auto;
}

#questions {
  margin: 5px 30px;
  display: inline-block
}
<div class="form-inline">
    <span id="questions">
        <label>How much will your house cost?</label>
        <input class="form-control" type="text" placeholder="input">
      </span>
    <span id="questions">
        <label>What is the most you can pay monthly?</label>
        <input class="form-control" type="text" placeholder="input">
      </span>
    <span id="questions">
        <label>What is your Current Monthly Rent?</label>
        <input class="form-control" type="text" placeholder="input">
      </span>
  </div>
  <div id='centered'>
    <button type="submit" class="btn btn-primary mb-2">Submit</button>
  </div>

If anyone could help me out, that would be greatly appreciated!

Answer №1

Understood!

All I needed to do was include text-align:center; within the span

#questions {
   margin:5px 30px;
   display:inline-block;
   text-align:center;
}

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

Placing Google Adsense among the content created using a JQuery loop

I have implemented a search function on my website that retrieves results from the database in JSON format. These results are then dynamically displayed by appending a DIV or SPAN element within a loop. $("#btnGetresult" ).click(function(e) { var ...

How can I create numerous HTML containers using Javascript?

I've been learning from this tutorial: Instead of just displaying the last database object, I want to display all of them. I have tried outputting the database contents and it's working fine. Now, I just need to adjust the HTML. I attempted to ...

Even after attempting to conceal objects using display:hidden, there is still whitespace present on the webpage

Check out my code in action on JsFiddle by visiting the following link: https://jsfiddle.net/2yvjm4h1/ Even after using display:none; to hide my objects rather than visibility:hidden before showing them with JavaScript, I still notice a significant amount ...

Bootstrap overrides the color of the calendar year in jQuery UI

I am facing an issue where the CSS styles of my jQuery UI calendar are being overridden by the Bootstrap CSS styles. Take a look at the screenshot provided. As you can see, the text color of the calendar's year is not black as intended. https://i.ss ...

Left-aligned arrow for Material UI select dropdown

Just starting out with material ui and I'm trying to grasp a few concepts. I have a basic select component but encountering two issues. Firstly, I'd like to move the arrow icon of the select to the left side instead of the right. Additionally, ...

Is there a way to modify the font color in Chrome when the input autofill feature is active?

I tried adding the css code below: input:-webkit-autofill{ color:white; } Unfortunately, it didn't have any effect. If anyone can assist me with this issue, I would greatly appreciate it. Thank you. ...

Tips for eliminating stuttering when fixing the position of an element with JavaScript

I am currently facing an issue with a webpage I created where the text freezes when scrolled down to the last paragraph, while the images continue to scroll. Although my implementation is functional, there is noticeable jankiness when using the mouse wheel ...

A guide on altering the pathway to locate React-bootstrap

Trying to incorporate modules from React-bootstrap has been a challenge for me. import logo from './logo.svg'; import './App.css'; import FormGroup from 'react-bootstrap/FormGroup' import ControlLabel from 'react-bootstra ...

Why is my browser failing to show spaces in list text when using the SELECT tag?

While using IE7, I noticed that the options in my SELECT tag are displayed without the leading spaces in the text - it appears that the text is being trimmed. For instance, in the HTML code block provided below, even though options 1 to 3 have three spaces ...

Troubleshooting CSS Problems in a Lightbox

I have developed a custom lightbox for watching Youtube videos that is fully functional. However, the design aspect leaves much to be desired. Please take a look at it. Despite my best efforts to improve it, the outcome is still not satisfactory. Here is ...

jQuery is great at adding a class, but struggles to remove it

When you click on an anchor with the class .extra, it adds the "extra-active" class and removes the "extra" class. However, when you click on an anchor with the extra-active class, it does not remove the extra-active class and replace it with extra. Here ...

What could be the reason for justify-self: flex-start not positioning the div at the bottom of a column?

I want to display a div in three levels: header, content, and footer. The content can vary in height and the footer should always be at the bottom. Here is how I have implemented it: <div class="news-content-block"> <div class=" ...

Troubleshooting issues with sending email with attachments in PHP and HTML

I've been having trouble sending an email with an attachment file; it just doesn't seem to work and I can't seem to receive any files. Although my HTML syntax appears correct, as I haven't received any bounce-back emails, the issue per ...

What is the best way to input individual students' CA and exam scores into distinct fields and then calculate their total scores in a separate text field?

As a beginner in jQuery, I am looking for guidance on creating a script that calculates the Total score, Grade, Remark, and Position based on the user input of CAT score and EXAM score. The result should be displayed dynamically once both scores are entere ...

The submit button remains unresponsive, yet upon removing its JavaScript code, it functions smoothly

This is the content of my index.html file. It contains JavaScript code. However, there seems to be a problem with the JavaScript validation as the Submit button does not perform any action when clicked. Surprisingly, when I remove the JavaScript code, the ...

"Enhancing User Experience by Enabling Full Clickability on List Items

I am working on a hamburger menu with a dropdown feature, and I want the entire dropdown menu to be clickable instead of just the text. Below is my current code which only allows clicking on the text. cshtml <nav class="navbar fixed-top navbar-dark bg ...

Ensuring Uniform Column Height in Bootstrap 4 - Preventing Buttons from Being Forced to the Bottom of

Using the Bootstrap 4 class 'h-100' to ensure equal height for all three columns, I encountered an issue where the buttons that were initially aligned to the bottom of each div are no longer in correct alignment. How can I maintain button alignme ...

Adjust the point color of landmarks in Face-api.js

I need to customize the pointColor and lineColor in my code, but I'm not sure how to do it. I am using the fast-api.js library and haven't come across any examples of customized Landmarks Styles. export const drawResults = async (image, canvas, r ...

Having trouble getting the drop down menu to function properly using HTML and CSS

I attempted to implement a drop-down menu using the following codes. However, I am facing some issues as clicking on the drop-down menu does not open the sub-menus as expected. Is there a way for me to resolve this problem? <div id="control-panel& ...

When the data-toggle="table" attribute is utilized, the content will be shown as plain text within the <td> element

While incorporating bootstrap data-toggle="table", an issue arises wherein it converts content within <td> into plain text disregarding any tags. https://i.sstatic.net/nuTLY.png The code snippet in question is as follows <!DOCTYPE html ...