Modifying a toggleable menu - html

Hello guys I have a login menu, that when you hit the element "log-in" it will drop down a loggin menu. The thing is that I can't move the log in box to the left.
The reason I want to do this is when the users use a smaller screen half of the box won't show up properly.
===============================================================
Sample code below:
#login-dp{
min-width: 250px;
padding: 14px 14px 0;
overflow:hidden;
background-color:rgba(255,255,255,.8);
}
#login-dp .help-block{
font-size:12px
}
#login-dp .bottom{
background-color:rgba(255,255,255,.8);
border-top:1px solid #ddd;
clear:both;
padding:14px;
}
#login-dp .social-buttons{
margin:12px 0
}
#login-dp .social-buttons a{
width: 49%;
}
#login-dp .form-group {
margin-bottom: 10px;
}
.btn-fb{
color: #fff;
background-color:#3b5998;
}
.btn-fb:hover{
color: #fff;
background-color:#496ebc
}
.btn-tw{
color: #fff;
background-color:#55acee;
}
.btn-tw:hover{
color: #fff;
background-color:#59b5fa;
}
#media(max-width:768px){
#login-dp{
background-color: inherit;
color: #fff;
}
#login-dp .bottom{
background-color: inherit;
border-top:0 none;
}
}
<li class="dropdown">
<b>Login</b> <span class="caret"></span>
<ul id="login-dp" class="dropdown-menu">
<li>
<div class="row">
<div class="col-md-12">
Login via
<div class="social-buttons">
<i class="fa fa-facebook"></i> Facebook
<i class="fa fa-twitter"></i> Twitter
</div>
or
<form class="form" role="form" method="post" action="login" accept-charset="UTF-8" id="login-nav">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Email address" required>
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password" required>
<div class="help-block text-right">Forget the password ?</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> keep me logged-in
</label>
</div>
</form>
</div>
<div class="bottom text-center">
New here ? <b>Join Us</b>
</div>
</div>
</li>
</ul>
</li>
</ul>

Related

Why is the "required" HTML attribute is not working?

As the heading suggests, the required attribute is not working, so I cannot seem to be able to validate my form.
I am creating an event registration form.
I have tried encapsulating each element inside form,but that doesn't seem to work.
What can I do to help with that? Please excuse me if the question is childish. I am a beginner, and I am trying to practice as much as I can.
......................................................................................................................................................
<html>
<head>
<style>
* {
box-sizing: border-box;
}
text-danger {
color: #e74c3c;
}
input[type=text], select, textarea {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
resize: horizontal;
}
legend {
font: bold 1.0em Arial, Helvetica, sans-serif;
color: #00008B;
background-color: #FFFFFF;
}
label {
padding: 12px 12px 12px 0;
display: inline-block;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
float: right;
}
input[type=submit]:hover {
background-color: #45a049;
}
.container {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
}
fieldset {
border: 1px solid #61B5CF;
margin-top: 1.4em;
padding: 0.6em;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.col-25, .col-75, input[type=submit] {
width: 100%;
margin-top: 0;
}
}
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
input:not([type=submit]):invalid {
background-color: #ffdddd;
}
input:not([type=submit]):valid {
background-color: #ddffdd;
}
input:not([type=submit]):invalid:required {
background: #ffdddd url('http://www.developerdrive.com/wp-content/uploads/2013/08/asterisk1.png') no-repeat right top;
}
input:not([type=submit]):valid:required {
background: #ddffdd url('http://www.developerdrive.com/wp-content/uploads/2013/08/asterisk1.png') no-repeat right top;
}
input:not([type=submit]):optional {
background-color: #add1ef;
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body>
<div class="container">
<h2> WIE ILS'19 Registration</h2>
<form novalidate="">
<fieldset>
<legend>Login Details</legend>
<div class="form-group">
<label class="col-md-2 control-label">E-Mail</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input name="email" placeholder="E-Mail Address" class="form-control" type="text" required>
</div>
</div>
</div>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" >Password</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="password" name="password" id="password" onchange='check_pass();' required>
</div>
</div>
</div>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label" >Confirm Password</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="password" name="confirm_password" id="confirm_password" onchange='check_pass();' required>
</div>
</div>
</div>
<br></br>
</form>
</fieldset>
<form>
<fieldset>
<legend>Personal Information</legend>
<form>
<div class="form-group">
<label class="col-xs-2 control-label">First Name</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="first_name" placeholder="First Name" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<!-- Text input-->
<form>
<div class="form-group">
<label class="col-xs-2 control-label" >Last Name</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="last_name" placeholder="Last Name" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<!-- Text input-->
<form>
<div class="form-group">
<label class="col-md-2 control-label">Contact No.</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
<input name="contact_no" placeholder="(+92)" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<form>
<div class="form-group">
<label class="col-md-2 control-label">CNIC No.</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="contact_no" placeholder="No-Hyphens" class="form-control" type="text" id="message" required>
<p class="help-block text-danger"></p>
</div>
</div>
</div>
</form>
<br></br>
</fieldset>
</form>
<form novalidate="">
<fieldset>
<legend>Education Details</legend>
<form>
<div class="form-group">
<label class="col-xs-2 control-label">University/Institute</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-education"></i></span>
<input name="first_name" placeholder="Institute Name" class="form-control" type="text" required>
</div>
</div>
</div>
</form>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-xs-2 control-label" >Degree Program </label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="last_name" placeholder="Last Name" class="form-control" type="text" required>
</div>
</div>
</div>
<br></br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-2 control-label">Semester</label>
<div class="col-md-3 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-tasks"></i></span>
<input name="contact_no" placeholder="" class="form-control" type="text" required>
</div>
</div>
</div>
<br></br>
</fieldset>
</form>
<form novalidate="">
<h5 style="font-weight:bold" >Do you need accomodation?</h5>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
<br>
<br>
<button type="submit" name="submit" value="registration" id="submit" disabled>Submit</button>
</div>
</form>
<script >
function check_pass() {
if (document.getElementById('password').value ==
document.getElementById('confirm_password').value) {
document.getElementById('submit').disabled = false;
} else {
document.getElementById('submit').disabled = true;
}
}
</script>
</body>
</html>
In order for the submit to work, you need to put it inside of the form that you would like to submit. There are other ways of doing it, but that usually incorporates JavaScript and JQuery. The reason it is preventing you from submitting when it is inside the form though, is due to the novalidate attribute on the form. Just remove that and you should be good to go!
P.S. Even though the field is required on the front-end, that is all client side so it's not hard to go in and change it. It's always a good idea to validate it on the back-end as well. Think of the front-end as more of a suggestion and less of a final verdict.

Header elements not positioning right in css

I currently have navigation bar elements in my header. All I want is for them to move to the right side of the screen because they are on the left right now. Anybody know why they won't move? Also is there some rule to positioning elements? I thought it would be as simple as telling them where I wanted them to go but apparently that's not the case.
html:
<div class="row">
<div class="col">
<!--Navigation bar-->
<header class="container-fluid">
<nav class="nav navbar-expand-sm">
<!--Search form-->
<div class="searchForm">
<form class="form-inline" action="">
<input type="text" name="search" class="form-control mr-sm-2" placeholder="Search">
</form>
</div>
<!--Navigation bar links-->
<ul class="navbar-nav">
<li class="nav-item">
Home
</li>
<li class="nav-item">
Register
</li>
<li class="nav-item dropdown">
Login
<!--Login dropdown form-->
<div class="dropdown-menu dropdown-menu-right">
<h3 class="dropdown-header">Log In</h3>
<form action="">
<div class="form-group loginInput">
<input type="email" name="email" id="email" class="form-control" placeholder="Email Address">
</div>
<div class="form-group loginInput">
<input type="password" name="password" class="form-control" id="password" placeholder="Password">
</div>
<!--Login Buttton-->
<button type="submit class=btn btn-primary">Log In</button>
</form>
</div>
</li>
</ul>
</nav>
</header>
</div>
</div>
CSS:
body{
background: #ecf0f1;
font-family: 'Open Sans', sans-serif;
}
header{
background-color: #2A2A36;
}
.bold{
font-weight: bold;
}
.loginInput input{
margin: 0 auto;
width: 150px
}
.dropdown-menu{
width: 200px;
height: 220px;
background:#1F2021;
opacity: 0.9;
}
.navbar-nav .nav-link{
color: #ecf0f1;
text-align: right;
}
.navbar-nav .nav-link:hover{
background:#d35400;
}
form{
margin: 0 auto;
}
.searchForm form{
height: 0px;
display: block;
}
*{
padding: 0;
margin: 0;
}
.navbar-nav .nav-item{
border-right: 1px solid #FFF;
}
.navbar-nav{
background:#2A2A36;
}
To position elements on the right you need to add this to your CSS code for class navbar-nav:
.navbar-nav
{
position:relative; // positioning relative to parent
float:right; // float right inside it's parent
list-style-type:none; // this is to remove the list dots (bullets)
background:#2A2A36;
}
Note: Your <form> and it's container div have 0px height. In case you didn't want that add a <br style="clear:both;" /> after the </form> tag in <div class="searchForm">. Although I see the height:0 in your CSS so that might be on purpose.
Here is the code:
body{
background: #ecf0f1;
font-family: 'Open Sans', sans-serif;
}
header{
background-color: #2A2A36;
}
.bold{
font-weight: bold;
}
.loginInput input{
margin: 0 auto;
width: 150px
}
.dropdown-menu{
width: 200px;
height: 220px;
background:#1F2021;
opacity: 0.9;
}
.navbar-nav .nav-link{
color: #ecf0f1;
text-align: right;
}
.navbar-nav .nav-link:hover{
background:#d35400;
}
form{
margin: 0 auto;
}
.searchForm form{
height: 0px;
display: block;
}
*{
padding: 0;
margin: 0;
}
.navbar-nav .nav-item{
border-right: 1px solid #FFF;
}
.navbar-nav
{
position:relative;
float:right;
list-style-type:none;
background:#2A2A36;
}
<div class="row">
<div class="col">
<!--Navigation bar-->
<header class="container-fluid">
<nav class="nav navbar-expand-sm">
<!--Search form-->
<div class="searchForm">
<form class="form-inline" action="">
<input type="text" name="search" class="form-control mr-sm-2" placeholder="Search">
</form>
</div>
<!--Navigation bar links-->
<ul class="navbar-nav">
<li class="nav-item">
Home
</li>
<li class="nav-item">
Register
</li>
<li class="nav-item dropdown">
Login
<!--Login dropdown form-->
<div class="dropdown-menu dropdown-menu-right">
<h3 class="dropdown-header">Log In</h3>
<form action="">
<div class="form-group loginInput">
<input type="email" name="email" id="email" class="form-control" placeholder="Email Address">
</div>
<div class="form-group loginInput">
<input type="password" name="password" class="form-control" id="password" placeholder="Password">
</div>
<!--Login Buttton-->
<button type="submit class=btn btn-primary">Log In</button>
</form>
</div>
</li>
</ul>
</nav>
</header>
</div>
</div>
You have to apply the effect to parent element of the elements you want them to move.
.nav{text-align:right;}
Instead of positioning with text-align: right; I would do this: position: relative; right: 5%; transform: translate(-50%); You can change "right" value depending in what you need. You can use both but always define in parent, in this case .nav{} . So you can use this:
.nav{
position: relative;
right: 5%;
transform: translate(-50%);
}
or this:
.nav{
text-align: right;
}
First one is better if you'll put images and is also responsive :)
The answer I found was to use ml-auto on the navbar.
html:
<nav class="nav navbar-expand-sm">
<!--Search form-->
<div class="searchForm">
<form class="form-inline" action="">
<input type="text" name="search" class="form-control mr-sm-2" placeholder="Search">
</form>
</div>
<!--Navigation bar links-->
<ul class="navbar-nav ml-auto">
<li class="nav-item">
Home
</li>
<li class="nav-item">
Register
</li>
<li class="nav-item dropdown">
Login
<!--Login dropdown form-->
<div class="dropdown-menu dropdown-menu-right">
<h3 class="dropdown-header">Log In</h3>
<form action="">
<div class="form-group loginInput">
<input type="email" name="email" id="email" class="form-control" placeholder="Email Address">
</div>
<div class="form-group loginInput">
<input type="password" name="password" class="form-control" id="password" placeholder="Password">
</div>
<!--Login Buttton-->
<button type="submit class=btn btn-primary">Log In</button>
</form>
</div>
</li>
</ul>
</nav>

Form input fields rendering issue with firefox

Would you know why the input fields of my form don't render well on firefox? (no issue with safari).
The issues are (1) the placeholder text is not visible with firefox (except for the message field) and (2) when you type something in these fields (name, email, etc) it is not visible.
Thanks for your help
See https://jsfiddle.net/qr0nvov9/
<section>
<div class="container">
<div class="row">
<div class="col-md-3 bordering">
<h2>Nous <b>contacter</b></h2>
<h3>A votre service</h3>
</div>
<div class="col-md-8 right-content">
<p>Toute l'équipe...</p>
<div class="grid-item contact-form">
<div class="inner">
<form id="form" action="/php/mail.php" name="form">
<div class="row">
<div class="col-md-6">
<input placeholder="* Your name" name="name" required type="text" class="form-control">
</div>
<div class="col-md-6">
<input placeholder="* E-mail" name="email" required type="email" class="form-control">
</div>
<div class="col-md-6">
<input placeholder="Phone number" name="phone" type="text" class="form-control">
</div>
<div class="col-md-6">
<input placeholder="Website" name="website" type="text" class="form-control">
</div>
<div class="col-md-12">
<textarea placeholder="* Message" name="message" required class="form-control"></textarea>
<button id="send" type="submit" class="btn btn-default">Send</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
add this downstream of your styles
form-control, .input-group-addon, input[type="number"] {
padding: 10px; /*just roughed this in*/
box-sizing: content-box;
}
Check this : https://jsfiddle.net/qr0nvov9/5/
replace this with old css:
.form-control,
.input-group-addon,
input[type=number] {
background: #CEF6DC;
border: 0;
border-bottom: 1px solid #2e2e2e;
border-radius: 0;
box-shadow: none;
padding: 0px 10px;
font-weight: 400;
margin-top: 10px;
color: #2e2e2e;
-webkit-transition: all .3s;
transition: all .3s;
height:50px;
}
input:active,
input:focus,
textarea:active,
textarea:focus {
outline: none!important;
box-shadow: none!important;
border-color: #2e2e2e!important;
/* background: #2e2e2e; */
padding: 0px 21px;
color: #2e2e2e!important
}

How can I line up this button with the textboxes?

I would like the left side of the button flush with the textboxes. I'm using bootstrap 3 if that makes a difference. Here is my html code for the form. I can add my CSS if that's necessary as well. Thank you.
h1 {
font-size:83px;
}
.btn-primary {
background: #ffffff;
border-color: #ffffff;
color: #f05324;
}
.btn-default, .btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default {
background: #ffffff;
border-color: #ffffff;
color: #f05324;
}
.panel-default {
border: none;
}
input[type="text"] {
color:white !important;
}
input[type="email"] {
color:white !important;
}
.model-content {
color:black !important;
}
.text-left {
text-align: left;
}
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
.navbar-default {
background-color: #000000;
}
body {
background: #f05324 !important;
margin-bottom: 80px;
color: #ffffff;
}
.page-header, .panel-body, .panel, .panel-default, .col-lg-9, .row {
background: #f05324 !important;
}
.form-control{
background-color: #f05324;
color: #000000;
}
hr {
border-color: #ffffff;
background-color: #ffffff;
color: #ffffff;
}
.link {
color: #ffffff;
}
.page-header {
margin-top: 0;
}
.panel-body {
padding-top: 0;
}
.img-featured {
margin-top : 15px;
margin-bottom: 15px;
margin-right : 15px;
}
.img-project{
margin-top : 15px;
margin-bottom: 15px;
}
.show-onclick {
display: none;
}
.show-onclick1 {
display: none;
}
.block {
position: absolute;
top: 0;
bottom: 0;
left: 50%;
margin-left: // half the width of your img
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<form class="form-horizontal" method="post" action="submit.php" enctype="multipart/form-data">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">NAME:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">EMAIL:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="email" name="email">
</div>
</div>
<div class="form-group">
<label for="phoneNumber" class="col-sm-2 control-label">PHONE:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="phone" name="phone">
</div>
</div>
<div class="form-group">
<label for="major" class="col-sm-2 control-label">MAJOR:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="major" name="major">
</div>
</div>
<hr>
<div class="form-group">
<label for="itemForSale" class="col-sm-2 control-label">ITEM FOR SALE:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="itemForSale1" name="itemForSale1">
</div>
</div>
<div class="form-group">
<label for="quantity" class="col-sm-2 control-label">QUANTITY:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="quantity1" name="quantity1">
</div>
</div>
<div class="form-group">
<label for="price1" class="col-sm-2 control-label">PRICE:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="price1" name="price1">
</div>
</div>
<div class="form-group">
<label for="itemOneImg1" class="col-sm-2 control-label">IMAGE 1:</label>
<div class="col-sm-10">
<input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg1">
</div>
</div>
<div class="form-group">
<label for="itemOneImg2" class="col-sm-2 control-label">IMAGE 2:</label>
<div class="col-sm-10">
<input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg2">
</div>
</div>
<input id="additional-files" type="button" value="Additional Projects" class="btn btn-default">
</form>
If you want the left edge of the button to match up with the left edge of the text boxes then you just need to add an offset using the Bootstrap grid as follows:
<form class="form-horizontal" method="post" action="submit.php" enctype="multipart/form-data">
...
<div class="form-group">
<label for="itemOneImg2" class="col-sm-2 control-label">IMAGE 2:</label>
<div class="col-sm-10">
<input type="file" accept=".jpg, .jpeg, .png" class="form-control" name="itemOneImg2">
</div>
</div>
<div class="form-group">
<!-- Adjust col-sm-X for the buttons to adjust their positioning
Could also add btn-block class to make the button span the column -->
<div class="col-sm-offset-2 col-sm-9">
<input id="additional-files" type="button" value="Additional Projects" class="btn btn-default">
</div>
<div class="col-sm-1">
<input id="submit" type="button" value="Submit" class="btn btn-default">
</div>
</div>
</form>
More details (and another example) can be found on the Bootstrap website: http://getbootstrap.com/css/#forms-horizontal
EDIT: Based on additional information in comments.

Bootstrap 3 - element won't stay in the width of the div

I am using bootstrap 3 in a small div. When I increase the window's width by dragging the window - the fields (username and password input fields) that are supposed to stay in the interior of the div move out to almost the center of the window. Why? CSS and HTML are below
<body>
<div class="login">
<div class="container">
<div class="col-md-12">
<div class="row">
<form action="https://www.blah/login"/>
<h3>Login</h3>
<div class="col-xs-4">UserName:</div>
<div class="col-xs-8"><input class="rounded white" type="text" name="username" placeholder="Username:" required/><br></div>
<div class="col-xs-4">Password:</div>
<div class="col-xs-8"><input class="rounded white" type="password" name="password" placeholder="Password:" required/><br></div>
<input type="checkbox" name="retrieve" value="true"/>I forgot my password.
<ul class="no-bullets">
<li><input class="color-brown white rounded float-left" type="submit" name="register" value="Submit Now"></li>
<li><input class="rounded margin-left-5px" data-dismiss="modal" type="submit" value="Cancel"></li>
</ul>
</div>
</div>
</div>
</div>
</body>
CSS----
.login {
height: 200px;
width: 330px;
max-width: 330px;
padding: 10px 20px 10px 20px;
background-color: #242424;
border: 1px solid #545454;
border-radius: 5px;
color: #ddd;
}
JS Fiddle
The elements containing your labels (.col-xs-4) have a width: 33.33333%.
The elements containing your input fields (.col-xs-8) have a width: 66.6666667%.
When the screen is narrow these width values are small and the labels and inputs are close together.
When the screen expands, these width values expand as well, creating a progressively larger gap between label and input.
The answer is to give the container a width constraint.
Add this style to the container class:
.col-md-12 { max-width: 250px; }
I tested it in Chrome and it works. Also, here's a live demo:
http://jsfiddle.net/y0psw5dn/
You seemed to inproperly set .login to height:200px.
.login{
/*height:200px*/
}
Is is what you want?
Try this.
<div class="login">
<div class="row">
<div class="col-md-12">
<form action="https://www.blah/login" />
<h3>Login</h3>
<div class="col-xs-4">UserName:</div>
<div class="col-xs-8">
<input class="rounded white" type="text" name="username" placeholder="Username:" required/>
<br>
</div>
<div class="col-xs-4">Password:</div>
<div class="col-xs-8">
<input class="rounded white" type="password" name="password" placeholder="Password:" required/>
<br>
</div>
<input type="checkbox" name="retrieve" value="true" />I forgot my password.
<ul class="no-bullets">
<li>
<input class="color-brown white rounded float-left" type="submit" name="register" value="Submit Now">
</li>
<li>
<input class="rounded margin-left-5px" data-dismiss="modal" type="submit" value="Cancel">
</li>
</ul>
</div>
</div>
</div>
.login {
height: 200px;
width: 330px;
max-width: 330px;
padding: 10px 20px 10px 20px;
background-color: #242424;
border: 1px solid #545454;
border-radius: 5px;
color: #ddd;
}
JSfiddle
Just put the .login div under the .container div. Below the code is
<div class="container">
<div class="login">
See the jsfiddle demo.
I changed your structure. There was some wrong. You can check this demo on jsfiddle
I also using Bootstrap 3 here Just Check it out this code.
Your HTML code structure is not organized here. First you need to understand its row and columns architecture what the purpose Behind it.
and Here on many places you open the div but you are not closing your at proper Location Where you need to close it.
I used this HTML Code :
<div class="container">
<div class="col-md-12 login">
<form action="https://www.blah/login"/>
<h3>Login</h3>
<div class="row">
<div class="col-xs-4">UserName:</div>
<div class="col-xs-8">
<input class="rounded white" type="text" name="username" placeholder="Username" required/><br>
</div>
</div>
<div class="row">
<div class="col-xs-4">Password:</div>
<div class="col-xs-8">
<input class="rounded white" type="password" name="password" placeholder="Password" required/><br>
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="checkbox" name="retrieve" value="true"/> I forgot my password.
</div>
</div>
<div class="row">
<div class="col-md-6">
<input class="bg-default btn-font" type="submit" name="register" value="Submit Now">
</div>
<div class="col-md-6">
<input class="bg-default btn-font" data-dismiss="modal" type="submit" value="Cancel">
</div>
</div>
</div>
and css code is here:
.login { height: 200px; width: 330px; max-width: 330px; padding: 10px 0px 10px 20px; background-color: #242424; border: 1px solid #545454; border-radius: 10px; color: #ddd; } .btn-font{ color: #000; }
and here is my running fiddle Example:
For Demo Click Here
hi please check below code it should be within container...
<div class="container">
<div class="login">
<div class="col-md-12">
<div class="row">
<form action="https://www.blah/login"/>
<h3>Login</h3>
<div class="col-xs-4">UserName:</div>
<div class="col-xs-8"><input class="rounded white" type="text" name="username" placeholder="Username:" required/><br></div>
<div class="col-xs-4">Password:</div>
<div class="col-xs-8"><input class="rounded white" type="password" name="password" placeholder="Password:" required/><br></div>
<input type="checkbox" name="retrieve" value="true"/>I forgot my password.
<ul class="no-bullets">
<li><input class="color-brown white rounded float-left" type="submit" name="register" value="Submit Now"></li>
<li><input class="rounded margin-left-5px" data-dismiss="modal" type="submit" value="Cancel"></li>
</ul>
</div>
</div>
</div>
check the demo here
Just change your upper starting structure of your html like this only
<div class="container">
<div class="row-fluid">
<div class="login">
the problem is with your html structure still many wrong things are
present you can make it better just try to improve by understanding the grid system of Bootstrap
it happens because of the improper structure sequence so that
here is the working demo jsfiddle
DEMO check out
here i tried to modify your code my way you can check out
.login {
height:280px;
max-width:250px;
padding: 10px 20px 10px 20px;
background-color: #242424;
border: 1px solid #545454;
border-radius: 5px;
color: #ddd;
}
.temp_div{
float: left;
margin-top: 10px;
}
.forgetPass_check{
padding-right:5px;
vertical-align:bottom;
padding-left: 15px;
}
.forgetPass_label{
padding-left:10px;
}
.no-bullets{
list-style-type: none;
margin: 0;
padding-left: 15px;
}
ul.no-bullets li{
float: left;
padding-right: 20px;
color:black;
}
<div class="container">
<div class="row-fluid">
<div class="login">
<form action="https://www.blah/login"/>
<h3 class="text-center">Login</h3>
<div class="col-xs-8"><label>UserName:</label><input class="rounded white" type="text" name="username" placeholder="Username:" required/></div>
<div class="col-xs-8"><label>Password:</label><input class="rounded white" type="password" name="password" placeholder="Password:" required/></div>
<div class="temp_div">
<div class="forgetPass_check">
<input type="checkbox" name="retrieve" value="true"/><label class="forgetPass_label">I forgot my password.</label>
</div>
<div class="button_wrapper">
<ul class="no-bullets">
<li><input class="color-brown white rounded float-left" type="submit" name="register" value="Submit Now"></li>
<li><input class="rounded margin-left-5px" data-dismiss="modal" type="submit" value="Cancel"></li>
</ul>
</div>
</div>
</div>
</div>
</div>
here is the demo code as well
Please Check Out Modified
even you can check this
Another try