Is there a way to align this button perfectly with the textboxes?

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

Is there a way to align the left side of the button with the textboxes in my form? I'm using bootstrap 3 for this. Here is the HTML code for my form. I can provide the CSS if needed. Thanks.

h1 {
    font-size:83px;
    }

    .btn-primary {
    background: #ffffff;
    border-color: #ffffff;
    color: #f05324;
    }

    .btn-default, .btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default {
        background: #ffffff;
    border-color: #ffffff;
    color: #f05324;
    }

    .panel-default {
        border: none;
    }

    input[type="text"] { 
    color:white !important;
    } 

    input[type="email"] { 
    color:white !important;
    } 

    .model-content {
    color:black !important;
    }

    .text-left {
      text-align: left;
    }

    .text-right {
      text-align: right;
    }

    .text-center {
      text-align: center;
    }

    .navbar-default {
        background-color: #000000;
    }

    body {
    background: #f05324 !important; 
    margin-bottom: 80px;
    color: #ffffff;
    }

    .page-header, .panel-body, .panel, .panel-default, .col-lg-9, .row {
    background: #f05324 !important; 
    }

    .form-control{
        background-color: #f05324;
        color: #000000;
    }

    hr {
    border-color: #ffffff;
    background-color: #ffffff;
    color: #ffffff;
    }

    .link {
    color: #ffffff;
    }

    .page-header {
    margin-top: 0;
    }

    .panel-body {
    padding-top: 0;
    }

    .img-featured {
    margin-top   : 15px;
    margin-bottom: 15px;
    margin-right : 15px;
    }

    .img-project{
    margin-top   : 15px;
    margin-bottom: 15px;
    }

    .show-onclick {
    display: none;
    }

    .show-onclick1 {
    display: none;
    }

    .block {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        margin-left: // half the width of your img
    }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

<form class="form-horizontal" method="post" action="submit.php" enctype="multipart/form-data">
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">NAME:</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="name" name="name">
    </div>
  </div>
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">EMAIL:</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="email" name="email">
    </div>
  </div>
  <div class="form-group">
    <label for="phoneNumber" class="col-sm-2 control-label">PHONE:</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="phone" name="phone">
    </div>
  </div>

  <div class="form-group">
    <label for="major" class="col-sm-2 control-label">MAJOR:</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="major" name="major">
    </div>
  </div>

  <hr>

  <div class="form-group">
    <label for="itemForSale" class="col-sm-2 control-label">ITEM FOR SALE:</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="itemForSale1" name="itemForSale1">
    </div>
  </div>

  <div class="form-group">
    <label for="quantity" class="col-sm-2 control-label">QUANTITY:</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="quantity1" name="quantity1">
    </div>
  </div>

  <div class="form-group">
    <label for="price1" class="col-sm-2 control-label">PRICE:</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="price1" name="price1">
    </div>
  </div>

  <div class="form-group">
    <label for="itemOneImg1" class="col-sm-2 control-label">IMAGE 1:</label>
    <div class="col-sm-10">
      <input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg1">

    </div>
  </div>

  <div class="form-group">
    <label for="itemOneImg2" class="col-sm-2 control-label">IMAGE 2:</label>
    <div class="col-sm-10">
      <input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg2">

    </div>
  </div>

  <input id="additional-files" type="button" value="Additional Projects" class="btn btn-default">
</form>

Answer №1

To ensure the alignment of the button's left edge with the text boxes, you can simply incorporate an offset using the Bootstrap grid system like this:

<form class="form-horizontal" method="post" action="submit.php" enctype="multipart/form-data">
    ...
    <div class="form-group">
        <label for="itemOneImg2" class="col-sm-2 control-label">IMAGE 2:</label>
        <div class="col-sm-10">
            <input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg2">
        </div>
    </div>

    <div class="form-group">
        <!-- Adjust col-sm-X for the buttons to fine-tune their placement
             You can also consider adding the btn-block class to make the button fill the column -->
        <div class="col-sm-offset-2 col-sm-9">
            <input id="additional-files" type="button" value="Additional Projects" class="btn btn-default">
        </div>
        <div class="col-sm-1">
            <input id="submit" type="button" value="Submit" class="btn btn-default">
        </div>
    </div>
</form>

For more information and examples, be sure to visit the Bootstrap website: http://getbootstrap.com/css/#forms-horizontal

UPDATE: Further insights based on comments received.

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 to use image source and mouse hover effects in CSS3

Can we create a CSS3 class for the src, onmouseout, and onmousehover properties? <img src="http://www.example.com//images/pic.png" onmouseout="this.src = 'http://www.example.com/images/pic.png'" onmouseover="this.src = 'http://www.examp ...

Adjust font size using jQuery and CSS styles

I'm currently working on a website where the body has a specified font-size property that is inherited by all elements on the page. Some tags on the page have font-sizes specified in percentages (%). Others are assigned sizes in pixels (px). I&apos ...

Tips on personalizing the checkbox by incorporating a custom background image

Looking to spruce up the standard checkbox? We're open to any method - whether it's a background image, CSS3, or some jQuery magic. Check out this example for inspiration! ...

Convert HTML content to a PDF file with Java

Welcome to the community! My project involves extracting data from a website containing information on various chemical substances and converting it into a PDF while preserving the original HTML formatting, including CSS styles. For example, here is a li ...

What is the best way to make a textview span its layout in an android app?

Is there a way to style text in a TextView layout itself without using any programming? I have about 20 XML files and no activity associated with them. I've tried using tags but it doesn't seem to work. android:text="Lets look how to make < ...

Failing to verify the presence of specific text within a dropdown menu using Selenium

Previously, I successfully implemented this code, however, the HTML/CSS for the dropdown has since changed and now I am unable to get it to function correctly. Below is the structure for the dropdown code, with specific text highlighted that I am trying t ...

Ensure the beginning and ending times are accurate for newly added input fields using jQuery

I've included a JSFIDDLE link here for reference. The validation for start and end time kicks in when the 'Next' button is clicked, located on the same page. I'm looking to validate the start and end times for dynamically generated fiel ...

Is it possible to dynamically change the color of text based on its position using CSS, JS, or JQuery?

I am currently working on a corporate website and have been tasked with creating a unique design for a specific page. The design includes the following elements: A body background gradient that transitions from their primary color to white in a top-to-bot ...

What steps can you take to ensure that a pre-loaded swf file occupies the entire browser

Allow me to elaborate on my query. I am currently designing a flash website and utilizing a small external preloader swf to load the main swf. I have successfully configured the preloader swf to occupy the entire browser window, however, once it loads in ...

Emphasize multiple anchor points

I am looking to highlight two sections of a page simultaneously. Here is what I currently have: <li class="langLI" style="list-style-type:none"><a href="/non-discrimination-and-language-assistance##French">| French Creole</a></li> ...

Styling CSS to place an image in between text and background coloring

As I try to replicate a happy accident of mine, which originally occurred during my first attempt at CSS: I was just randomly adding selectors when I stumbled upon this unique layout. However, as I proceeded with rewriting the file, I failed to save the o ...

Learn how to use Bootstrap to style your buttons with centered alignment and add a margin in between each one

Looking to center four buttons with equal spacing between them? Here's what you can do: |--button--button--button--button--| Struggling with manual margin adjustment causing buttons to overlap? Check out this code snippet: <div id=""> ...

Upon clicking on a different div, a div will elegantly slide down from above the footer

I'm struggling with sliding a div from the bottom of the page. Here is my JSFIDDLE Currently, when I click on the blue box (arrow-hover), the div slides up (box-main). However, to hide the div (box-main) again, I have to click inside the box-main d ...

Trigger the animation with a button click by utilizing ng-class in Angular.js

How can I make an animation run more than once when a button is clicked? I've tried using ng-class but it's not working as expected. Any help would be appreciated. Thank you! <div ng-controller="MyCtrl"> <div class='contendor_port ...

Tips for utilizing the setInterval function in javascript to update the background color of the body

Currently, I am tackling a project for my course and I am seeking to modify the body's background color on my website randomly by leveraging the setInterval technique in my JavaScript file. Any suggestions on how to achieve this task? ...

Angular: Radio button groups are not responding correctly when populated within a loop using ng-repeat

My goal is to populate multiple sets of radio buttons in a loop by combining the group name and index to ensure each set is uniquely grouped. However, I am facing an issue where only the last group in the loop has a checked radio button, while all other gr ...

Why isn't my custom HTML attribute displaying correctly?

In my current React app project, I have been incorporating custom attributes to HTML tags and React components for End-to-End (E2E) tests using Testcafe. However, I am facing an issue where the additional data-test="burger-menu-btn" attribute is ...

Implementing template loading on page load with state in AngularJS

When my application loads, I want the nested view list-patents.htm to be displayed. The main navigation is on my index.htm, featuring two nav items: transactions and patents. If you click on patents, two sub-menu items will appear: list patents and add p ...

Is there a way to change the color of the menu button to white if the points are not visible?

I have created CSS to style the menu's color and make the buttons change color based on different actions. However, I also want the buttons to match the colors of the points on the map. To achieve this, I set the background color in JavaScript when ge ...

Tips for adjusting the size of a container to fit its child element in a flexbox layout, where the flex-direction is set to column

Below is the functional code: .container{ display: flex; background-color: lightgreen; justify-content: center; alighn-item: center; } .child{ margin-left: 10px; height: 200px; background-color: yellow; display: flex; flex-direction: ...