Align a div and a label horizontally - html

I have a asp.net form that contains tags.I want to align a label side by side that div horizontally.But i cant manage what i do.I have added my code snippet below.Can you help me please?
My Code Snippet
<div class="modal" id="passwordModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Şifre Değiştirme</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="inputPassword">Şifreniz</label>
<input class="form-control" runat="server" placeholder="Şuanki Şifreniz" type="password" id="inputPassword" />
</div>
<div class="form-group">
<label for="inputNewPassword">Yeni Şifreniz</label>
<input class="form-control" runat="server" placeholder="Yeni Şifreniz" type="password" id="inputNewPassword" />
</div>
<label id="labelAlign">How Can i align this label near the div above</label>
<div class="form-group">
<label for="inputNewPasswordAgain">Yeni Şifreniz Tekrar</label>
<input class="form-control" runat="server" placeholder="Yeni Şifreniz Tekrar" type="password" id="inputNewPasswordAgain" />
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btn_PasswordChange" class="btn btn-primary" runat="server" OnClick="btn_PasswordChange_Click" Text="Değiştir" />
<asp:Button ID="btn_PasswordClose" class="btn btn-primary" runat="server" data-dismiss="modal" Text="Kapat" />
</div>
</div>
</div>
</div>

Why not add the label class within the given div?
<div class="form-group">
<label for="inputNewPassword">Yeni Şifreniz</label>
<input class="form-control" runat="server" placeholder="Yeni Şifreniz" type="password" id="inputNewPassword" />
<label id="labelAlign">How Can i align this label near the div above</label>
</div>
Or add inline-block to the div:
<div class="form-group" style="display:inline-block">
Snippet:
.trial {
display: inline-block;
}
<div class="modal" id="passwordModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Şifre Değiştirme</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="inputPassword">Şifreniz</label>
<input class="form-control" runat="server" placeholder="Şuanki Şifreniz" type="password" id="inputPassword" />
</div>
<div class="form-group trial">
<label for="inputNewPassword">Yeni Şifreniz</label>
<input class="form-control" runat="server" placeholder="Yeni Şifreniz" type="password" id="inputNewPassword" />
</div>
<label id="labelAlign">How Can i align this label near the div above</label>
<div class="form-group">
<label for="inputNewPasswordAgain">Yeni Şifreniz Tekrar</label>
<input class="form-control" runat="server" placeholder="Yeni Şifreniz Tekrar" type="password" id="inputNewPasswordAgain" />
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btn_PasswordChange" class="btn btn-primary" runat="server" OnClick="btn_PasswordChange_Click" Text="Değiştir" />
<asp:Button ID="btn_PasswordClose" class="btn btn-primary" runat="server" data-dismiss="modal" Text="Kapat" />
</div>
</div>
</div>
</div>

Does this helps you?
label{
width: 170px;
position: relative;
display: inline-flex;
}
input{
width: 180px;
position: relative;
display: inline-flex;
}
.modal-body{
position: absolute;
}
<div class="modal" id="passwordModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Şifre Değiştirme</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="inputPassword">Şifreniz</label>
<input class="form-control" runat="server" placeholder="Şuanki Şifreniz" type="password" id="inputPassword" />
</div>
<div class="form-group trial">
<label for="inputNewPassword">Yeni Şifreniz</label>
<input class="form-control" runat="server" placeholder="Yeni Şifreniz" type="password" id="inputNewPassword" />
</div>
<div class="form-group">
<label for="inputNewPasswordAgain">Yeni Şifreniz Tekrar</label>
<input class="form-control" runat="server" placeholder="Yeni Şifreniz Tekrar" type="password" id="inputNewPasswordAgain" />
</div>
</div>
</div>
</div>
</div>

Related

How to make Bootstrap modal content side by side?

Newbie to bootstrap.I followed the bootstrap 4 documentation to create a simple modal.
Bootstrap 4 modal
And created a modal with two parts - Part 1 and Part 2 separated by a <hr> tag.
I couldn't succeed in putting the two parts - Part 1 and Part 2 side by side.
Link to modal:
CodePen modal
Here is my sample modal:
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalLong">Launch demo modal</button>
<!-- Modal -->
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span>
</button>
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
</div>
<div class="modal-body">
<form>
<h4>Part 1</h4>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4">Email</label>
<input type="email" class="form-control" id="inputEmail4" placeholder="Email">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4">Password</label>
<input type="password" class="form-control" id="inputPassword4" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="inputAddress">Address</label>
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
</div>
<div class="form-group">
<label for="inputAddress2">Address 2</label>
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputCity">City</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="form-group col-md-4">
<label for="inputState">State</label>
<select id="inputState" class="form-control">
<option selected>Choose...</option>
<option>...</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="inputZip">Zip</label>
<input type="text" class="form-control" id="inputZip">
</div>
</div>
<div class="form-group">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" value="">Check me out <span class="form-check-sign">
<span class="check"></span>
</span>
</label>
</div>
</div>
<hr>
<h4>Part 2</h4>
<form>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4">Email</label>
<input type="email" class="form-control" id="inputEmail4" placeholder="Email">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4">Password</label>
<input type="password" class="form-control" id="inputPassword4" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="inputAddress">Address</label>
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
</div>
<div class="form-group">
<label for="inputAddress2">Address 2</label>
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputCity">City</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="form-group col-md-4">
<label for="inputState">State</label>
<select id="inputState" class="form-control">
<option selected>Choose...</option>
<option>...</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="inputZip">Zip</label>
<input type="text" class="form-control" id="inputZip">
</div>
</div>
<div class="form-group">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" value="">Check me out <span class="form-check-sign">
<span class="check"></span>
</span>
</label>
</div>
</div>
</form>
</form>
</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>
<!-- Modal -->
Is there any article to refer to or any suggestions to proceed further?
Try this:
<form>
<div class="row">
<div class="col-6">first side</div>
<div class="col-6">second side</div>
</div>
<form>
And also you should change your modal width.

How can I fix this weird line that comes with Boostrap model when having two div with col-lg-6 ?

I have a boostrap model , I see a weird line in it when having two divs with col-lg-6. Can you please tell me why and help me to fix it ?
This is the model code
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Create</h4>
</div>
<form method="post" id="insert_form">
<div class="modal-body">
<div class="col-lg-6">
<div class="form-group">
<label for="Code">Code</label>
<input type="text" class="form-control" id="Code" name="Code" />
</div>
<div class="form-group">
<label for="Name">Name</label>
<input type="text" class="form-control" id="Name" name="Name" />
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="CanSale">Sale</label>
<input type="text" class="form-control" id="CanSale" name="CanSale" />
</div>
<div class="form-group">
<label for="Barcode">Barcode</label>
<input type="text" class="form-control" id="Barcode" name="Barcode" />
</div>
<div class="form-group">
<label for="Code">Descriptoin</label>
<input type="text" class="form-control" id="Description" name="Description" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" name="insert" id="insert" value="Insert" class="btn btn-success" />
</div>
</form>
</div>
below image red arrows shows the weird line that i am talking about. Please help me fix it.
I forget to place "col" divs inside <div class="row">.
I got it fixed by nesting "col-lg-6" divs inside <div class="row"> </div>

Two buttons in different forms side by side

i have two forms. One form for login and the other form for reset the password.
Now i want to set the both buttons (login, password reset) side by side.
But i don't know, how to do that.
And here is my code:
<form action="login" method="POST">
<div class="row">
<div class="col-md-2">Username:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="text" name="username" id="username" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2">Passwort:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="password" name="password" id="password" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2 input-group-sm">
<input type="submit" class="form-control btn-default" value="Login" />
</div>
</div>
</form>
<form action="reset" method="POST">
<div class="row">
<div class="col-md-2 input-group-sm">
<input class="form-control btn-default" type="submit" value="Passwort vergessen" />
</div>
</div>
</form>
I hope you can help me.
Keep the button elements in same form and add form attribute to the other button to which you want to associate with other form element.
From MDN:
The form element that the button is associated with (its form owner). The value of the attribute must be the id attribute of a element in the same document. If this attribute is not specified, the element will be associated to an ancestor element, if one exists. This attribute enables you to associate elements to elements anywhere within a document, not just as descendants of elements.
Example:
<form id="firstForm">
<button>Submit First form</button>
<button form="secondForm">Submit Second form</button>
</form>
<form id="secondForm">
</form>
Give your second form an id (e.g. "form2"), and add this CSS:
#form2 {
position: relative;
bottom: 25px;
left: 55px;
}
i changed css of two buttons, now it works, here you can run, nd see it's working now.
i added style="float:left;" in <input type="submit" class="form-control btn-default" value="Login"/> and <input class="form-control btn-default" type="submit" value="Passwort vergessen"/>
<form action="login" method="POST">
<div class="row">
<div class="col-md-2">Username:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="text" name="username" id="username" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2">Passwort:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="password" name="password" id="password" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2 input-group-sm">
<input type="submit" class="form-control btn-default" value="Login" style="float:left;" />
</div>
</div>
</form>
<form action="reset" method="POST">
<div class="row">
<div class="col-md-2 input-group-sm">
<input class="form-control btn-default" type="submit" value="Passwort vergessen" style="float:left;" />
</div>
</div>
</form>
<style>
#resetForm {
position: relative;
bottom: 37px;
left: 55px;
}
</style>
<form action="login" method="POST">
<div class="row">
<div class="col-md-2">Username:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="text" name="username" id="username" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2">Passwort:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="password" name="password" id="password" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2 input-group-sm">
<input type="submit" class="form-control btn-default" value="Login" />
</div>
</div>
</form>
<form action="reset" method="POST">
<div class="row" id="resetForm">
<div class="col-md-2 input-group-sm">
<input class="form-control btn-default" type="submit" value="Passwort vergessen" />
</div>
</div>
</form>
If you want to put the buttons side by side you can add the css property float: left; to the login button and it'll work, but it'll work only for this example.
<form action="login" method="POST">
<div class="row">
<div class="col-md-2">Username:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="text" name="username" id="username" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2">Passwort:</div>
<div class="col-md-4 input-group input-group-sm">
<span class="input-group-addon" id="important">
<span class="glyphicon glyphicon-play" />
<input class="form-control" type="password" name="password" id="password" aria-describedby="important" />
</span>
</div>
</div>
<div class="row">
<div class="col-md-2 input-group-sm">
<input type="submit" class="form-control btn-default" value="Login" style="float:left; />
</div>
</div>
</form>
<form action="reset" method="POST">
<div class="row">
<div class="col-md-2 input-group-sm">
<input class="form-control btn-default" type="submit" value="Passwort vergessen" />
</div>
</div>
</form>
Important note:
I don't think it's a good idea to use a form only for a button element, you should think of using it in the same form and apply the float: left; property to the buttons, it makes more sense and it's better for your DOM.
Better way to do
You should not use a second form to reset your first form.
You have to use only one form and add an input with type="reset"
By this way you can place your buttons side by side in only one line and reset works !
<div class="col-md-2 input-group-sm">
<input type="submit" class="form-control btn-default" value="Login" />
<input type="reset" value="Reset"/>
</div>
Live demo :
https://jsfiddle.net/20o2ahnr/

Bootstrap modal form is so ugly

I need help i cant figure out why my modal login form is not conforming to any changes and doesn't look like the standard bootstrap form.
nav.php
<!-- Modal HTML -->
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Login</h4>
</div>
<div class="modal-body">
<p>Please log in below</p>
<form action="#" method="post" accept-charset="UTF-8">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="label" for="user" style="color: black">Username</label></br>
<input id="user" type="text" name="user" size="30" class="input-large" placeholder="username" required/>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="label" for="pass"style="color: black">Password</label></br>
<input id="pass" type="text" name="pass" size="30" class="input-large" placeholder="Password"required/>
</div>
</div>
<label class="string optional" for="user_remember_me"> Remember me</label> <input id="user_remember_me" style="float: left; margin-right: 10px;" type="checkbox" name="user[remember_me]" value="1" />
<input class="btn btn-success" style="clear: left; width: 100%; height: 32px; font-size: 13px; margin-bottom: 6px;" type="submit" name="submit" value="submit" />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
here is what it looks like
here is an example of what i want it to look like
The documentation is your friend. Forms, inputs, and their labels need form-group and form-control (among other classes) attached to them.
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
</div>
</form>

Size of login form is too large

Ive got my login form too wide, it takes 80% of the pages width as you could see the picture below.
I'm using default bootstrap.min.css
Heres the html code i use
<div class="modal-body">
<h3>Login with your CZCNR account!</h3>
<form name="regitration" method="POST" action="check.php" class="af-form " id="af-form-rf">
<div class="af-outer af-required">
<div class="form-group af-inner">
<input type="text" name="username" id="name-rf" size="30" value="" placeholder="Nickname" class="form-control placeholder pull-right" />
<label class="error" for="name-rf" id="name_error_rf">Nickname is required.</label>
</div>
</div>
<div class="af-outer af-required">
<div class="form-group af-inner">
<input type="password" name="password" id="phone-rf" size="30" value="" placeholder="Password" class="form-control placeholder" />
<label class="error" for="phone-rf" id="phone_error_rf">Password is required.</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-theme-sm btn-theme" data-dismiss="modal">Close</button>
<button class="btn btn-theme-sm btn-theme btn-theme-primary">Login</button>
</div>
</form>
</div>
Any help would be appreciated
Thanks in advance.
Try this
HTML
<div class="row">
<div class="col-md-6 col-md-offset-2">
<div class="modal-body ">
<h3>Login with your CZCNR account!</h3>
<form name="regitration" method="POST" action="check.php" class="af-form " id="af-form-rf">
<div class="af-outer af-required">
<div class="form-group af-inner">
<input type="text" name="username" id="name-rf" size="30" value="" placeholder="Nickname" class="form-control placeholder pull-right" />
<label class="error" for="name-rf" id="name_error_rf">Nickname is required.</label>
</div>
</div>
<div class="af-outer af-required">
<div class="form-group af-inner">
<input type="password" name="password" id="phone-rf" size="30" value="" placeholder="Password" class="form-control placeholder" />
<label class="error" for="phone-rf" id="phone_error_rf">Password is required.</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-theme-sm btn-theme" data-dismiss="modal">Close</button>
<button class="btn btn-theme-sm btn-theme btn-theme-primary">Login</button>
</div>
</form>
</div> </div> </div>
Demo Here
You can add a width style attribute in your very first div tag.
<div class="modal-body" style="width:400px;">
<h3>Login with your CZCNR account!</h3>
<form name="regitration" method="POST" action="check.php" class="af-form " id="af-form-rf">
<div class="af-outer af-required">
<div class="form-group af-inner">
<input type="text" name="username" id="name-rf" size="30" value="" placeholder="Nickname" class="form-control placeholder pull-right" />
<label class="error" for="name-rf" id="name_error_rf">Nickname is required.</label>
</div>
</div>
<div class="af-outer af-required">
<div class="form-group af-inner">
<input type="password" name="password" id="phone-rf" size="30" value="" placeholder="Password" class="form-control placeholder" />
<label class="error" for="phone-rf" id="phone_error_rf">Password is required.</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-theme-sm btn-theme" data-dismiss="modal">Close</button>
<button class="btn btn-theme-sm btn-theme btn-theme-primary">Login</button>
</div>
</form>
</div>