Bootstrap form styling within modal window - css

I have stuck with that for a while. I have a bunch of inputs within my modal window to create a season. But it is still not responsive (looks very bad on smaller screens).
Also those two buttons should be on the right side of the well. I tried things like "pull-right" class or "float left" and absolute position but then they are always cross the grey background. How can I fix that?
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="pull-left">Seasons</h3>
</div>
<div class="modal-body" style="position: relative;">
<div class="well">
<div class="row" style="width: 80%; margin: 0;">
<div class="col-sm-6">
<span class="bold">Season name</span>
<input type="text" placeholder="e.g. High season">
</div>
<div class="col-sm-3">
<span class="bold">From</span>
<input type="date" style="font-size: 1.23rem; display: inline-block;">
</div>
<div class="col-sm-3">
<div style="margin-left: 40px;">
<span class="bold">To</span>
<input type="date" style="font-size: 1.23rem;display: inline-block;">
</div>
</div>
</div>
<br>
<button type="button" class="btn btn-default" data-dismiss="modal" style="position: absolute; right: 50px;">Close</button>
<button type="button" class="btn btn-primary" style="position: absolute; right: 20px;">Save</button>
</div>
</div>
</div>
And code online goes here: http://www.bootply.com/ojhdwC4y4x#

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="pull-left">Seasons</h3>
</div>
<div class="modal-body">
<div class="well">
<div class="input-group">
<input type="text" class="form-control" placeholder="Season name" aria-describedby="basic-addon1">
</div>
<div class="input-group">
<input type="text" class="form-control" placeholder="From" aria-describedby="basic-addon1">
</div>
<div class="input-group">
<input type="text" class="form-control" placeholder="To" aria-describedby="basic-addon1">
</div>
</div>
<br>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
It caused by <span> tag before <input> tag, I think. And let's try above code, using bootstrap input instead.
And result:

<div class="row" style="width: 80%; margin: 0;">
<div class="col-sm-6">
<span class="bold">Season name</span>
<input class="form-control" type="text">
</div>
<div class="col-sm-3">
<span class="bold">From</span>
<input class="form-control" type="date">
</div>
<div class="col-sm-3">
<span class="bold">To</span>
<input class="form-control" type="date">
</div>
</div>
how about to change it default of bootstrap style?

For the buttons you should use modal-footer like described here. For the responsive code try this:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="pull-left">Seasons</h3>
</div>
<div class="modal-body">
<div class="well">
<div class="row">
<div class="col-sm-5">
<span class="bold">Season name</span>
<input type="text">
</div>
<div class="col-sm-3">
<span class="bold">From</span>
<input type="date" style="font-size: 1.23rem;">
</div>
<div class="col-sm-3">
<span class="bold">To</span>
<input type="date" style="font-size: 1.23rem;">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
Note that the modal component has limted size, and rows define some margins, but the native HTML 5 date will not fit on the well div nicely. So you can remove one column from "Season name". If you have a lot more elements I recomend divide them on multiple rows.

Related

Two exact same modals - One wont show up - Bootstrap modal show black screen

Iam just getting my feet wet for a very small website. I am completely new at HTML,CSS,JS,Bootstrap,etc. I am self-learning as I go. That said...
I am trying to make this page have two modals with different information on each, but one gives a black screen out.
<!-- Modal -->
<div class="modal fade" id="loginModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form>
<div class="modal-header">
<h1 class="modal-title">
User Login
</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Email address</label>
<input type="email" class="form-control">
</div>
<div class="mb-4">
<label class="form-label">Passwort</label>
<input type="passwort" class="form-control">
</div>
<div class="d-flex align-items-center justify-content-between mb-2">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="regModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog-lg">
<div class="modal-content">
<form>
<div class="modal-header">
<h1 class="modal-title">
User Login
</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Email address</label>
<input type="email" class="form-control">
</div>
<div class="mb-4">
<label class="form-label">Passwort</label>
<input type="passwort" class="form-control">
</div>
<div class="d-flex align-items-center justify-content-between mb-2">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
</div>
</div>
</div>

Black Screen Modal Pop-up bootstrap in asp.net

I'm working on asp.net with bootstrap design.
I had implemented the modal pop-up on button click.
Unfortunately I'm facing the grey color over my pop-up and without any functionality working. If I click any where the modal pop-up is closing bu the grey color is always appearing until I do refresh.
My code :
<div class="table-responsive">
<table id="Table1" class="table">
<thead>
<tr>
<th>Type</th>
<th>Price</th>
<th>View</th>
<th>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal">Take Appointment</button>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
Modal pop-up :
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Appointment Details</h4>
</div>
<div class="modal-body">
<div class="row text-center">
<div class="col-sm-3 col-xs-3">
<div class="form-group">
<label class="control-label">Type Name:</label>
</div>
</div>
<div class="col-sm-6 col-xs-6">
<div class="input-group">
<asp:TextBox ID="txtName" runat="server" placeholder="Enter Type Name" class="form-control"></asp:TextBox>
</div>
</div>
</div>
<div class="row text-center">
<div class="col-sm-3 col-xs-3">
<div class="form-group">
<label class="control-label">Price:</label>
</div>
</div>
<div class="col-sm-6 col-xs-6">
<div class="input-group">
<asp:TextBox ID="TextBox1" runat="server" placeholder="Enter Price" class="form-control"></asp:TextBox>
</div>
</div>
<div class="col-sm-3 col-xs-3">
</div>
</div>
<div class="input-group col-md-12 input-append" data-date-format="dd/mm/yyyy" id="divDateOfBirth">
<input class="date-picker form-control Datevalidate hasDatepicker" data-val="true" data-val-regex="Please enter valid value" data-val-regex-pattern="^(?:(?:31(\/)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$" data-val-required="Please enter valid value" id="txtRESIDENT_SINCE" maxlength="10" name="RESIDENT_SINCE" onkeypress="return isDate(event)" placeholder="dd/mm/yyyy" type="text" value="" autocomplete="off">
<!--<input id="date-picker-2" type="text" class="date-picker form-control">-->
<span class="input-group-addon">
<span class="glyphicon glyphicon-remove" id="residentHideCal" onclick="clearCal(this)"></span>
</span><span id="SpanDob1" class="input-group-addon showdp">
<span class="glyphicon glyphicon-calendar" id="residentShowCal" onclick="showCal(this)"></span>
</span>
</div>
<div class="clockpicker">
<div class="input-group clockpicker">
<input type="text" class="form-control" value="09:30">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
<script type="text/javascript">
$('.clockpicker').clockpicker();
</script>
</div>
</div>
<div class="modal-footer">
<button runat="server" class="btn btn-primary btn-sm" data-dismiss="modal">Submit</button>
<button type="button" class="btn btn-default btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
My current result :

Align Bootstrap form input fields across multiple rows inside a modal

Specifically, the problems are:
The first row wraps to a second line
The input fields do not line up vertically
It might be possible to use a table, but that might break responsiveness on mobile devices. Is there a clean/elegant way to align these input fields?
https://codepen.io/dtgq/pen/rwQRoK
For posterity, a copy of the HTML on the codepen:
<div class="modal fade" id="fjFilterModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Filter</h5>
<button type="button" class="close" data-dismiss="modal">
<span>×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group row">
<label class="col-form-label col-md-2">Cost</label>
<div class=col-md-10>
<div class="form-inline">
<div class="form-group mx-2">
<div class=input-group>
<span class=input-group-addon>$</span>
<input class=form-control name="max_cost-gte" type=number placeholder="Minimum" step=1 min=0>
<span class=input-group-addon>.00</span>
</div>
</div>
to
<div class="form-group mx-2">
<div class=input-group>
<span class=input-group-addon>$</span>
<input class=form-control name="min_cost-lte" type=number placeholder="Maximum" step=1 min=0>
<span class=input-group-addon>.00</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-form-label col-md-2">Start date</label>
<div class=col-md-10>
<div class="form-inline">
<div class="form-group mx-2">
<input class="form-control" type="date" name="min_date-gte">
</div>
to
<div class="form-group mx-2">
<input class="form-control" type="date" name="min_date-lte">
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-form-label col-md-2">Available units</label>
<div class=col-md-10>
<div class="form-inline">
<div class="form-group mx-2">
<div class=input-group>
<input class=form-control name="sum_vacant-gte" type=number min=0 placeholder="Minimum">
<span class=input-group-addon>units</span>
</div>
</div>
to
<div class="form-group mx-2">
<div class=input-group>
<input class=form-control name="sum_vacant-lte" type=number min=0 placeholder="Maximum">
<span class=input-group-addon>units</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn" data-toggle="modal" data-target="#fjFilterModal">
Filter
</button>

Print scrollable boootstrap modal

I have one modal in my new web application ,I want to print the modal content,the modal is scrollable.Now i can only print the content that is viewable.What are the corrections that i should make in my style.css.
index.html
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 ALIGN="center" class="modal-title">MR FINANCE</h4>
</div>
<div class="modal-body" >
<div class="row">
<div class="col-xs-6">
<div class="form-group">
Name:<input type="text" ng-model="cstmrname" class="form-control" placeholder="Jane Doe" >
</div>
<div class="form-group">
Phone:<input type="number"ng-model="cstmrphone" class="form-control" placeholder="8086502009">
</div>
</div>
<div class="col-xs-6 ">
<div class="text-right">
<p ><STRONG >GLID:{{(GLID.GLID-0)+1}}</STRONG></p>
{{date | date:'MM-dd-yyyy'}}<br/>
{{place}}
</div>
<div class="form-group">
Address: <textarea type="text" class="form-control" ng-model="cstmradress" rows="2"></textarea>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-xs-12">
<h4 align="center">
Ornaments
</h4>
<form class="form-inline form-group">
<fieldset data-ng-repeat="choice in choices">
<div class="col-xs-3">
<div class="form-group">
<select class="form-control" id="optioin1" ng-model="choice.option1" >
<option value="Ring" >Ring</option>
<option value="Earings" >Earings</option>
<option value="Chains">Chains</option>
<option value="Necklaces">Necklaces</option>
<option value="Bangles">Bangles</option>
</select>
</div>{{choice.option1}}
</div>
<div class="col-xs-4">
<div class="input-group">
<input type="number" step="0.01" ng-model="choice.weight" class="form-control" placeholder="Weight" aria-describedby="basic-addon2">
<span class="input-group-addon" id="basic-addon2">gm</span>
</div>
</div>
<div class="col-xs-4 pull-right">
<button class="btn btn-default" ng-show="$last" ng-click="removeChoice() "><span class="glyphicon glyphicon-minus" aria-hidden="true"></span></button>
<button class="btn btn-default" ng-show="$last" ng-click="addNewChoice()"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
</div>
</fieldset>
</form>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<p class="text-left"> Total Numbers:{{ choices.length}}</p>
</div>
<div class="col-xs-6"><p>Total Weight: {{total(number)}}gm</p>
</div>
</div>
<hr>
<form align="center" class="form-inline">
PledgeAmt:
<div class="input-group">
<input type="number" ng-model="pledgeamt" class="form-control" placeholder="{{(total()*2050)-3000}}-{{total()*2050}}" >
<span class="input-group-addon" id="basic-addon2">RS</span>
</div>
</form>
<hr>
<div class="row">
<h5 align="center"> Interest</h5>
<div class="col-xs-6">
<p> 1-3Month:{{ intrst[0].INTR1}}%({{(pledgeamt/100)*1}}RS/day)</p>
</div>
<div class="col-xs-6">
<p > 3-12Month:{{ intrst[0].INTR2}}%({{(pledgeamt/100)*2}}RS/day)</p>
</div>
</div>
<tr ng-repeat="ornament in data">
<td>{{ornament.GLID}}</td>
<td>{{ornament.WEIGHT}}</td>
<td>{{ornament.TOTGRAM}}</td>
</tr>
<div class="modal-footer">
<button type="button" ng-click="insertvalue()" class="btn btn-default" >Submit</button>
<button type="button" class="btn btn-default" onclick="js:window.print()">print modal content</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
style.css
.printable { display: none; }
#media print
{ .modal-footer,
.non-printable { display: none; }
.printable1 {
width: auto;
height: auto;
overflow: visible !important; }
}
You implementation of your css is the right approach but you will need to make whatever the class that currently has the scroll, visible when you print out the document.
If you wanted the css to be changed but not the html:
#media print {
/* if modal-body is your scrollable class */
.modal-body {
width: auto;
height: auto;
overflow: visible !important;
}
}
Code pen link

My Bootstrap form modal form doesn't display properly

I am trying to add a modal editing form to a page using Bootstrap. The idea is that when the user picks an item from the grid, an editing form should pop up showing current values and allowing them to make changes. Here's the code for the modal form:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="form-horizontal" id="myForm" role="form">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">My modal</h4>
</div>
<div class="modal-body">
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbTitle">Public Title:</label>
<div class="input-group col-sm-5">
<input type="text" runat="server" class="form-control required" id="tbTitle">
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbInternalTitle">Internal Title:</label>
<div class="input-group col-sm-5">
<input type="text" runat="server" class="form-control required" id="tbInternalTitle">
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbPrice">Monthly Price:</label>
<div class="input-group col-sm-5">
<input type="text" runat="server" class="form-control required" id="tbPrice">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
Now, the thing is, when I click the "Edit" button on a row in the GridView control on the page, it does what it should - it retrieves the plan data and populates the form fields. I know this, because if I examine the page source after clicking an item, here's what I see in the HTML:
<div class="container-fluid page-top">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="form-horizontal" id="myForm" role="form">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">My modal</h4>
</div>
<div class="modal-body">
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbTitle">Public Title:</label>
<div class="input-group col-sm-5">
<input name="ctl00$cpMain$tbTitle" type="text" id="cpMain_tbTitle" class="form-control required" value="Basic Gold Program" />
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbInternalTitle">Internal Title:</label>
<div class="input-group col-sm-5">
<input name="ctl00$cpMain$tbInternalTitle" type="text" id="cpMain_tbInternalTitle" class="form-control required" value="BASEPLAN" />
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbPrice">Monthly Price:</label>
<div class="input-group col-sm-5">
<input name="ctl00$cpMain$tbPrice" type="text" id="cpMain_tbPrice" class="form-control required" value="$75.00" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
However, when viewing the page normally and clicking the "Edit" button for a row, here's a screenshot of what actually appears:
I odn't know why the form data itself doesn't show up, but it's driving me nuts! I don't seem to have any HTML errors (unclosed tags, etc.), so I can't track down what's happening here. Any help?
I put your code into a snippet and it works... odd.
If you can see a correct HTML in the browser's console then maybe it's a css problem.
You should try to set a height property to be sure...
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container-fluid page-top">
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<div class="modal fade" id="myModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="form-horizontal" id="myForm" role="form">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">My modal</h4>
</div>
<div class="modal-body">
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbTitle">Public Title:</label>
<div class="input-group col-sm-5">
<input name="ctl00$cpMain$tbTitle" type="text" id="cpMain_tbTitle" class="form-control required" value="Basic Gold Program" />
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbInternalTitle">Internal Title:</label>
<div class="input-group col-sm-5">
<input name="ctl00$cpMain$tbInternalTitle" type="text" id="cpMain_tbInternalTitle" class="form-control required" value="BASEPLAN" />
</div>
</div>
</div>
<div class="form-group has-feedback">
<div class="col-lg-12">
<label class="control-label col-sm-3" for="tbPrice">Monthly Price:</label>
<div class="input-group col-sm-5">
<input name="ctl00$cpMain$tbPrice" type="text" id="cpMain_tbPrice" class="form-control required" value="$75.00" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
Well, the issue was how I was calling the modal form to open. I had to use a different JavaScript function to invoke it, since the other one worked but was buggy in some way. The Javascript function is:
function openModal() {
$('#myModal').modal('show');
}
and it's called from the server side with this:
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
The other one I was using didn't quite get it right, although the modal still appeared. Weird, but it worked. Thanks for the feedback, guys!

Resources