Bringing columns together when working with Bootstraps - asp.net-mvc

I have several textboxes within Bootstrap columns that I want to bring closer to one another, but no matter what I do the distance between textboxes stays the same.
How can I
Shorten the distance between the textboxes?
Shorten/make more narrow the column background or bring the textbox closer to the outside of a column
Here is the code that I have
<div class="col-xs-12 col-md-2">
<div class="well form-group">
<div class="bisformdynamiclabel">Box 1</div>
<input class="form-control" type="text" asp-for="myclass.box1" />
<span asp-validation-for="myclass.box1" class="alert-danger"></span>
</div>
</div>
<div class="col-xs-12 col-md-2">
<div class="well form-group">
<div class="bisformdynamiclabel">Box 2</div>
<input class="form-control" type="text" asp-for="myclass.box2" />
<span asp-validation-for="myclass.box2" class="alert-danger"></span>
</div>
</div>
<div class="col-xs-12 col-md-2">
<div class="well form-group">
<div class="col-lg-1">
<div class="bisformdynamiclabel">Box 3</div>
<input class="form-control" type="text" asp-for="myclass.box3" />
<span asp-validation-for="myclass.box3" class="alert-danger"></span>
</div>
</div>
</div>
Thank you in advance for everyone's help

Related

Concatenate asp-validation-for result with an Icon

I have an ASP MVC view that contains only a Textbox that takes a string, and a submit button to submit the value.
I want to add the validation error message with an Icon before it as in the following snippet:
<div class="form-group row">
<label class="col-sm-4 col-form-label">Check User Id</label>
<div class="col-sm-8">
<input asp-for="#Model.userId" type="text" class="form-control" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label"></label>
<div class="col-sm-8">
<input type="submit" class="btn btn-primary" value="Check" asp-action="Index" asp-controller="UserController" />
<div class="col-sm-8">
<i asp-validation-for="userId" class="fa fa-info-circle"></i>
<span asp-validation-for="userId" class="text-dark"></span>
</div>
</div>
</div>
My Problem now is that the info Icon is always showing, and I want it to show ONLY if there is an error/validation message. Is there a way to achieve that from the view only with no changes to the Business logic?

How to place objects in one line [Bootstrap 5]

I need it in one line, how to fix this?
Use the Bootstrap 5 grid system (ensure you are including the Bootstrap 5 css url)
Example:
<div class="container">
<div class="row">
<div class="col">
Column
</div>
<div class="col">
Column
</div>
<div class="col">
Column
</div>
</div>
</div>
https://getbootstrap.com/docs/5.0/layout/grid/
Your code would look, something like this:
<div class="d-none d-lg-block d-xl-block">
<div class="nav-item">
<div class="row">
<div class="col">
<form class="d-flex" action="search.php" method="get">
<input class="form-control me-2 px-3" type="search" placeholder="Search" name="search" aria-label="Search">
</form>
</div>
<div class="col">
<button class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#loginmodal">Login</button>
<button class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#signupmodal">Sign Up</button>
</div>
</div>
</div>
</div>
You could also put the signup button into a column on its own.
Add your buttons inside the form, or add d-flex to your nav-item class
Like this:
<div class="nav-item d-flex">

Bootstrap 4 input field spacing in Chrome on IOS

I've got an issue I cannot seems to figure out. I have a simple form for four text input fields. The spacing looks great on all the browsers except for Chrome on IOS. The spacing between the input fields just seems to be ignored.
I'm using Bootstrap 4. Here's the HTML:
<div class="form-row">
<div class="col-md-2 col-lg-2 col-sm-5 col-6 pt-2">
<input type="text" class="form-control form-control-sm bg-color-light-gray2" placeholder="First name">
</div>
<div class="col-md-2 col-lg-2 col-sm-5 col-6 pt-2">
<input type="text" class="form-control form-control-sm bg-color-light-gray2" placeholder="Last name">
</div>
<div class="col-md-3 col-lg-3 col-sm-3 col-6 pt-2">
<input type="text" class="form-control form-control-sm bg-color-light-gray2" placeholder="E-Mail">
</div>
<div class="col-md-2 col-lg-2 col-sm-2 col-6 pt-2">
<input type="tel" class="form-control form-control-sm rounded bg-color-light-gray2" placeholder="Zip Code" name="loanzip" id="loanzip" maxlength="5" value="" />
</div>
<div class="col-md-3 col-lg-3 col-sm-5 col-12 search-results pt-2">
<button type="submit" class="btn btn-success btn-block btn-sm rounded font-size-15">Get Approved <i class="fa fa-thumbs-up" aria-hidden="true"> </i></button>
</div>
So frustrating when it looks Ok everywhere else.
Enclosed is a screen shot from Chrome on IOS.
Thanks for any help!
Tim
Here it is on mobile Safari...
Latest HTML but leaves extra spacing after the button only on IOS Chrome.
<form name="carloan" id="carloan" action="car-loan-application/" method="post">
<div class="row ml-2 mr-2">
<div class="col-6 col-xl-2 mb-2">
<input type="text" class="form-control form-control-sm bg-color-light-gray2" placeholder="First Name">
</div>
<div class="col-6 col-xl-2 mb-2">
<input type="text" class="form-control form-control-sm bg-color-light-gray2" placeholder="Last Name">
</div>
<div class="col-6 col-xl-2 mb-2">
<input type="email" class="form-control form-control-sm bg-color-light-gray2" placeholder="E-Mail">
</div>
<div class="col-6 col-xl-2 mb-2">
<input type="tel" class="form-control form-control-sm bg-color-light-gray2" placeholder="Zip Code">
</div>
<div class="col-12 col-xl-4 mb-2 search-results">
<button type="submit" class="btn btn-success btn-block btn-sm rounded font-size-15">Get Approved <i class="fa fa-thumbs-up" aria-hidden="true"></i></button>
</div>
</div>
</form>
In your code, I can see your using col-md-3 which is for tablets, you are to use "col-xs (portrait device) or col-sm (landscape device)" depending on the width on IOS device. Or you can just use media queries or bootstrap 4 form-group class for your div (for a proper view). E.g.
<div class="form-group"> input or form button... </div>

bootstrap grid and columns for 7 fields or more

I am using below code for fields more then 7 button fields are scattered
<div class="panel-body">
<div class="row">
<div class="col-xs-12 ">
<fieldset class="well well-sm"><legend class="k-widget">main part1</legend><br>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">Name1: <field here >...... </div>
same for next 7 or more fields.
I get my fields in scattered manner means not inline, I want my first four field in first row and then next four in second row and on... but using this code appeares scattered.
EDIT:
I attempted to fix the code from what you provided, and it puts 4 forms in a row, then 4 in the next row, etc (on mobile screens the forms will be stacked to fit the screen)
See my example here: https://jsfiddle.net/vvp5rey8/
Here is the code:
<div class="panel-body">
<div class="row">
<div class="col-xs-12 ">
<fieldset class="well well-sm"><legend class="k-widget">main part1</legend> <br>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name1: <field here >......
</div>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name2: <field here >......
</div>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name3: <field here >......
</div>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name4: <field here >......
</div>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name5: <field here >......
</div>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name6: <field here >......
</div>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name7: <field here >......
</div>
<div class="col-xs-12 col-sm-3">
<label class="control-label" for="AppEducSclName">
Name8: <field here >......
</div>
</div>
</div>
</div>
Is that what you're looking for?

Bootstrap input-group-addon alignment issue in ASP.NET View

I can't seem to align an input-group-addon correctly in an ASP.NET View.
<form asp-action="Create">
<div class="form-horizontal">
<h4>Category</h4>
<hr />
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Hex" class="col-md-2 control-label"></label>
<div class="col-md-10">
<div class="input-group">
<div class="input-group-addon"><i></i></div>
<input asp-for="Hex" class="form-control" value="" />
<span asp-validation-for="Hex" class="text-danger" />
</div>
</div>
</div>
<div class="form-group">
<label asp-for="CompanyId" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="CompanyId" asp-items="Model.Companies" class="form-control">
<option value="">--Please Select--</option>
</select>
</div>
</div>
<div class="form-group">
<label asp-for="Name" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
</form>
This looks fine in JSFiddle (after adding labels back in). But looks like this when I run the View:
If I swap the input-group-addon and the input the addon floats off to the right.
Could this be something to do with the way a child View is rendered by the _layout view?
Could this be something to do with the way a child View is rendered by the _layout view?
Yup. Especially with renderbody.

Resources