Troubleshooting Boostrap Check Box Styling Problem in MVC 5

My registration form has a problem with the checkbox's alignment. I want the text to appear to the left of the checkbox, in line with the placeholders for the input fields on the page.

Currently, the text is either above the checkbox (centered in its own label) or below it. Below is the code for my Register page and related CSS. I'm struggling to figure this out, so any help would be greatly appreciated.

Register Page

<div class="row">
    <article class="span7">
        <section class="block-indent-1 maxheight">
            <h2>@ViewBag.Title.</h2>
            <p>Please ensure your details are entered accurately as they are crucial for website access and operation.</p>
            <p>Note that fields marked with an asterisk * must be filled out to register.</p>
        </section>
    </article>
    <article class="span5">
        <section class="block-indent-1 divider-left maxheight">
            <h2>Sign Up Here</h2>
            @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @id = "contact-form", role = "form" }))
            {
                @Html.AntiForgeryToken()
                @Html.ValidationSummary("", new { @class = "text-danger" })
                <fieldset>
                    <div class="form-div-5">
                        <label>
                            @Html.DropDownListFor(model => model.TitleId, TitleModel.TitleList)
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label>
                            @Html.DropDownListFor(model => model.SexId, SexModel.SexList)
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label>
                            @Html.TextBoxFor(m => m.Forename, new { @placeholder = "Forename *", @type = "text", required = "required" })
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label>
                            @Html.TextBoxFor(m => m.Surname, new { @placeholder = "Surname *", @type = "text", required = "required" })
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label>
                            @Html.TextBoxFor(m => m.Email, new { @placeholder = "Email Address *", @type = "email", required = "required" })
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label>
                            @Html.TextBoxFor(m => m.UserName, new { @placeholder = "Username *", @type = "text", @pattern = "[a-zA-Z0-9]{6,}", @title = "Your username must have no spaces or special characters and must be at least 6 characters long.", required = "required" })
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label>
                            @Html.PasswordFor(m => m.Password, new { @placeholder = "Password *", @type = "password", required = "required" })
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label>
                            @Html.PasswordFor(m => m.ConfirmPassword, new { @placeholder = "Confirm Password *", @type = "password", required = "required" })
                        </label>
                    </div>
                    <div class="form-div-5">
                        <label class="checkbox-inline">
                            @Html.CheckBoxFor(m => m.AcceptsTerms) @Html.LabelFor(m => m.AcceptsTerms)
                        </label>
                    </div>
                    <div class="button-wrapper">
                        <input type="submit" class="button" value="Register" /> <input type="reset" value="Reset" name="MFReset" class="button"><span>* Required Fields</span>
                    </div>
                </fieldset>
            }
        </section>
    </article>
</div>

CSS Style

#contact-form {
  position: relative;
  z-index: 1;
  margin: 0 0 20px;
  padding: 6px 0 0 0;
  vertical-align: top;
  font-family: Arial, Helvetica, sans-serif;
}
...

I would greatly appreciate any assistance with this issue. Thank you!

Answer №1

To optimize your code, consider replacing LabelFor with DisplayNameFor as you already have a wrapping label.

<label class="checkbox-inline">
    @Html.CheckBoxFor(m => m.AcceptsTerms) @Html.DisplayNameFor(m => m.AcceptsTerms)
</label>

Appreciate the suggestion!

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

What is the best way to create a 6-column grid system without using bootstrap?

I am looking to create a row with 2 columns that should turn into 2 separate rows, each containing one column when viewed on smaller devices. I have researched CSS Grid but find it quite complex. Can someone simplify it for me? Thank you! ...

Problems with the design in the Opera browser

My website logo is displaying incorrectly in Opera, despite working fine in Firefox and Chromium. I've been trying to troubleshoot this issue for the past few hours with no success. The ID of the logo element is 'Logo'. You can view the sit ...

Looking to determine if a specific element is assigned multiple class names

Help needed! Can you tell me how to check if an element contains more than one classname using pure javascript, without using jQuery? For example: If #test has both the classnames "classA and classB", then { alert(true) } else { alert(false) } Here is ...

Spacing between table cells is only applied to the first row and footer

In an attempt to add spacing between the first row, second row, and footer of a table, I have experimented with cell spacing combined with border-collapse. However, the spacing is being applied all over the table instead of in specific areas. I am utilizin ...

The Angular carousel fails to display or operate properly

I am encountering an issue where the content is not displaying when using the angular-carousel directives: <ul rn-carousel rn-carousel-controls rn-carousel-index="carouselIndex" rn-carousel-buffered > <li ng-repeat="slide in slides track by ...

"Enhancing Your Website with a Preloader Loading GIF: Step-by-Step Guide

Can anyone assist me in implementing a preloader with a 'loading' gif image on my website that will display for a maximum of 5 seconds before the site fully loads? I've attempted various methods without success, so any help would be greatly ...

The div is not showing the image as expected

Having some trouble creating a slideshow within my angular application. Struggling to get the images to display in the html code. To tackle this, I decided to create a separate component specifically for the slideshow (carousel.component). In the main app ...

Using HTML symbols can alter the height of the text

It seems like I'm making a mistake - whenever I try to include an HTML symbol before a word, the following word without the HTML symbol ends up with a different height and is not on the same line. https://i.sstatic.net/PhARi.jpg ...

Implementing Bootstrap in Wordpress using functions.php

The code snippet below is stored in my functions.php file within a Child theme directory. <?php function theme_styles() { wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/bootstrap.min.css' ); wp_enqueue_ ...

Navigating the absence of Prismic's ability to use the <blockquote> element in their rich text editor

My experience with Prismic as a headless CMS has been mostly positive, but I recently encountered an issue that surprised me - the lack of support for a simple blockquote. It's baffling to me that such a basic HTML element is not natively supported by ...

Adding a custom source to the script tag in Angular 7

I am currently using angular cli to develop my web application. The app is being built in the dist folder as of now. This is the index.html file: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Adm ...

Increase the size of the class element when hovered over

I have assigned a class to the "next" and "previous" functions on my webpage, and I am interested in increasing their size on hover so that they take up more space and push the other elements aside. For example: When I hover over the NEXT button, I want i ...

The issue of JQuery recursion not properly focusing on a textbox

Can anyone help with a jquery focus issue I'm experiencing? My goal is to address the placeholder problem in IE by focusing on an element and then blurring it to display the placeholder. This functionality is being used in a modal form. Initially, e ...

Creating a straightforward text/logo design for your HTML website?

After creating a standard website using HTML and PHP, I am now looking to add an exciting text/logo effect for when users first visit the site. Essentially, I want the logo to break apart and transition into loading the homepage once a user lands on the si ...

What is the proper way to structure an Xpath search?

Recently, I've been working with Selenium in QA Test automation. When it comes to selecting/writing Xpath for an element, I've noticed that there are different formats that can be used. For example, protected final String LOGIN_BUTTON_LOCATOR = ...

What is the most efficient way to send multiple arrays by selecting checkboxes?

Currently, I am faced with a challenge where I have a selection of items from a list that need to be submitted in the form of three different arrays with distinct values to PHP. These arrays include: Device id, Client comment, and Manufacturer comment. < ...

The navigation bar toggle feature seems to be malfunctioning in Bootstrap 5

I've encountered a problem with the navbar while using Bootstrap 5.0.2 dist. The toggler on the navbar expands and collapses, but it doesn't roll back after clicking the bar icon. I have implemented the fixed-top navbar from the Bootstrap 5 examp ...

Designing a unique layout using the Bootstrap grid system

Can someone help me achieve a responsive bootstrap grid layout as shown below? If screen size is equal to or greater than 576px: https://i.sstatic.net/v44dE.png If screen size is less than 576px: https://i.sstatic.net/mnPPp.png Thank you for your assist ...

Fill the center circle with GoJs background

Is there a specific way to paint the center circle only? I have provided an example project below. ...

What methods should I employ to rectify this asymmetrical border?

Within my HTML and CSS table, I've noticed that the first column has a different height compared to the rest. It appears uneven with the columns on its right. Please execute the code snippet below. The specific block I'm referring to is labeled ...