Issues with HTML Labels disrupting Bootstrap Grid Columns layout

Here is the HTML code I am working with:

<div class="row">
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @*@Html.LabelFor(s => s.BasicInfo.FirstName)*@<label>First Name:</label>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @Html.TextBoxFor(s => s.BasicInfo.FirstName)
    </div>
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @*@Html.LabelFor(s => s.BasicInfo.LastName)*@<label>Last Name:</label>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @Html.TextBoxFor(s => s.BasicInfo.LastName)
    </div>
</div>
<div class="row">
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @*@Html.LabelFor(s => s.BasicInfo.City)*@<label>City:</label>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @Html.TextBoxFor(s => s.BasicInfo.City)
    </div>
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @*@Html.LabelFor(s => s.BasicInfo.State)*@<label>State:</label>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
        @Html.TextBoxFor(s => s.BasicInfo.State)
    </div>
</div>

After testing in IE and Firefox, it seems that the layout only works correctly for "xs", "md", and "lg" sizes, but encounters issues with the "sm" size. Interestingly, removing the <label> tag resolves the issue for all sizes. Is there a problem with this combination of HTML/Razor/CSS? I have tried researching online for similar issues with placing other HTML elements within a column, but haven't found any related problems. Unfortunately, my attempted screenshots were not visible, so I had to remove them.

Answer №1

Initially, eliminating .col-xs-12 and .col-lg-3 will preserve the layout.

Additionally, while the code appears to be correct, it would be beneficial to view the complete generated code.

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

Is it feasible to capture a screenshot of a URL by using html2canvas?

Is it possible to take a screenshot of a specific URL using html2canvas? For example, if I have the following URLs: mydomain.com/home mydomain.com/home?id=2 mydomain.com/home/2 How can I capture and display the screenshot image on another page? window ...

What is the best way to assign a JavaScript return value to a PHP variable?

Is it possible to capture the return value of a JavaScript function that checks if text boxes are empty and assign it to a PHP variable? I have successfully created a JavaScript function that returns false if any of the text boxes are empty, but now I ne ...

Are there various types of HTML5 document declarations available?

Back in the days when I used to create web pages in XHTML, there were three types of doctype available - strict, transitional, and frameset. Are these different types of doctypes still present in HTML5? ...

Can you explain the significance of the jz element in HTML?

When visiting this particular page, it was noticed that the well-known ad blocking software successfully removed ads positioned near the top and right of the page. However, unexpectedly, this software added a brand new section of clickbait ads located just ...

Is there a way for me to remove an uploaded image from the system

Here is an example of my HTML code: <input type='file' multiple/> <?php for($i=0;$i<5; $i++) { ?> <div class="img-container" id="box<?php echo $i ?>"> <button style="display: none;" type="submit" cl ...

Modifying Table Cell Backgrounds Based on Value in React Tables

I am currently utilizing reactstrap to design my table and employing axios to interact with my backend data. The objective is to dynamically change the background color of a cell based on its value. For instance, if the cell value is less than 0.25, it sh ...

I am interested in limiting the amount of products a user can enter to ensure it does not exceed the quantity available in

I need to limit the user's input for a quantity field so that it does not exceed the available stock. In the JavaScript code below, qty represents the quantity fetched from the server, and #quantity is the input box with the default value set to 1. I ...

What is the best way to align the middle element of a flex row in the center?

Desired Outcome: I have three elements within a container styled with display: flex. My goal is to align the left item to the left, the right item to the right, and have the middle item centered. space-between does not achieve this look due to the varyin ...

Concealing the map on the webpage using Javascript (iframe)

Here is an excerpt from my code: <div id='content'> <div id='map'></div> <iframe name="content-wrapper"></iframe> </div> <div class="sidebar"> <div class="container"> <h2 ...

Reduce the width beyond the necessary limit

I'm struggling to adjust the width of an image to match it with the card size without stretching it or breaking the layout. Most solutions I've come across recommend using inline-block, but this doesn't work well for smaller images. It seems ...

How to automatically close a JavaScript popup once a form is submitted and refresh the parent page

I am facing an issue with a popup on my website. I have a separate page called math.ejs that pops up when a button is pressed on the index.ejs page. However, after clicking the submit Ok button in the math.ejs popup, I want it to close and display the calc ...

Modify the useRef value prior to the HTML rendering (React functional component)

Hello everyone, I am attempting to update the value of useRef before the HTML is rendered. I have tried using useEffect for this purpose, but it runs after the HTML is ready, making it unsuitable for my needs. What I want to achieve is resetting the value ...

The layout generated by Metronic does not display the CSS styles

I've been working on creating a Metronic layout using the layout builder, but I'm running into an issue. Whenever I try to open index.html, all I see is this: screenshot It appears that the CSS styles are not loading properly. Interestingly, wh ...

Dividing content into tabs using Python Flask

Here is a code snippet I'm currently working on: content.py import fnmatch import os matches = [] for root, dirnames, filenames in os.walk("Z:\\"): for filename in fnmatch.filter(filenames, '*.iso'): matches.appen ...

The Bootstrap navigation bar is struggling to contain all of the list items,

Recently, I started working with the latest version of Bootstrap and encountered an issue with the navigation bar. Everything looks great until I start resizing the browser width. While other Bootstrap components adjust well to the resize, the list items i ...

Using JavaScript to interact with text elements in external SVG documents

When it comes to creating an SVG within HTML and assigning specific IDs to text elements for easy access, everything works smoothly. For example, I can easily retrieve the ID using: let callQSO = document.getElementById("QSOcall").value; and th ...

Submitting an AJAX form redirects to a different page instead of keeping the user on the current page

I've encountered an issue with my popup ajax form. Instead of staying on the same page after data submission, it redirects me to send.php file. This behavior is different from another website where I successfully implemented a similar form. I'm n ...

Display when moving up and conceal when moving down

Is there a way to make the div appear when scrolling up and down on the page? I'm new to jquery and could use some assistance, please. ...

Utilizing Bootstrap's responsive design to create optimal spacing between boxes

I have designed this webpage layout using Bootstrap. Although I have manually added margin between the rows, I now want to include vertical spacing between the columns when the page is resized. Can anyone help me achieve this? Full-size browser: Resize ...

Troubleshooting innerHTML in jQuery

<script> $(document).ready(function() { var msg='{"ui":{"callData":[{"Title":"Caller Details", "Text":"<html><body><table border=&quot;1&quot;><tr><td>Caller details content</td></tr>< ...