CSS Media query for grouping float-start bootstrap5.2 - css

I ve impleemented an email form in html/css using bootstrap 5.2.
It looks good in the desktop view as well as in the mobile view but it has some issues in the medium sized screens.
I want the string "Given name:" (#given_name_text) to jump to the next line as soon as it's input field (#given_name_input) is jumping to the next line. The problem is present in the range of (min-width: 520px) and (max-width: 991px), that s why I ve already set up the media query, but I do not know what to enter.
Please find my html and css attached.
I am very greatfull for any hint!
moussioG4
#surname_text {
font-weight: 700;
width: 90px;
}
#surname_input {
width: 300px;
height: 30px;
margin-bottom: 20px;
}
#given_name_text {
font-weight: 700;
width: 130px;
text-align: right;
}
#given_name_input {
width: 300px;
height: 30px;
margin-bottom: 20px;
}
#email_text {
font-weight: 700;
width: 140px;
}
#email_input {
width: 300px;
height: 30px;
margin-bottom: 20px;
}
#message_text {
font-weight: 700;
width: 160px;
}
#message_input {
width: 100%;
height: 250px;
margin-bottom: 20px;
}
#message_button {
width: 130px;
height: 30px;
margin-bottom: 20px;
background-color: #f46530;
font-weight: 700;
color: #E7E7E7;
border: 3px solid #0c0c0c;
}
#message_button:hover {
background-color: #0c0c0c;
}
#media (max-width: 519px) {
#given_name_text {
text-align: left;
}
}
#media (min-width: 520px) and (max-width: 991px) {
}
<div id="main-content" class="container">
<h1>Contact Us</h1>
<p>Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form
Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form Use this form
</p>
<div id="name_input" class="row">
<label for="surname_input" id="surname_text" class="float-start">Surname:</label>
<input id="surname_input" class="float-start" type="text">
<label for="given_name_input" id="given_name_text" class="float-start">Given name:</label>
<input id="given_name_input" class="float-start" type="text">
</div>
<div id="mail_input" class="row">
<label for="email_input" id="email_text" class="float-start">E-mail address:</label>
<input id="email_input" class="float-start" type="email">
</div>
<label for="meessage_input" id="message_text">Your message:</label>
<input id="message_input" type="text">
<button type="button" id="s">Send message</button>
</div>
Picture of issue

In case somebody has a similar issue: Solved it by applying the following grid:
<div id="name_input" class="row">
<div class="col-lg-6 col-md-12">
<label for="surname_input" id="surname_text">Surname:</label>
<input id="surname_input" type="text">
</div><!-- End of surname input -->
<div class="col-lg-6 col-md-12">
<label for="given_name_input" id="given_name_text">Given name:</label>
<input id="given_name_input" type="text">
</div><!-- End of given name input -->
</div><!-- End of name input -->

Related

Bootstrap smaller input and smaller input-group-addon issue

I have used this in my CSS to create an smaller input field:
.input-xs {
height: 22px;
padding: 2px 5px;
font-size: 12px;
line-height: 1.5; /* If Placeholder of the input is moved up, rem/modify this. */
border-radius: 3px;
}
But of course I need to adjust the input-group-addon as well or it will look like this.
To prevent this and make the input-group-addon smaller, I have added this to my CSS.
.input-group-xs > .form-control,
.input-group-xs > .input-group-addon,
.input-group-xs > .input-group-btn > .btn {
height: 22px;
padding: 2px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
But it looks like this now.
Any suggestions to get it aligned again?
Complete code
<div class="input-group-xs form-group" id="div_exp_aantal['.$i.']">
<input type="number" min="0" class="form-control input-xs" id="exp_aantal['.$i.']" name="exp_aantal" placeholder="Huidige aantal" value="'.$row_list['aantal_huidig'].'" onkeyup="validate_exp(this, '.$i.')" onmousemove="validate_exp(this, '.$i.')">
<span class="input-group-addon">stuk</span>
</div>
If I were you, I'd add the class name "input-group" before the "input-group-xs" in order to add the base css.
.input-group {
position: relative;
display: table;
border-collapse: separate;
}
So your code should look like this:
<div class="input-group input-group-xs form-group" id="div_exp_aantal['.$i.']">
<input type="number" min="0" class="form-control input-xs" id="exp_aantal['.$i.']" name="exp_aantal" placeholder="Huidige aantal" value="'.$row_list['aantal_huidig'].'" onkeyup="validate_exp(this, '.$i.')" onmousemove="validate_exp(this, '.$i.')">
<span class="input-group-addon">stuk</span>
</div>

Bootstrap 3 daterangepicker not taking 100% width

I'm using custom datepicker (https://github.com/eternicode/bootstrap-datepicker) inside my form (http://jsfiddle.net/Misiu/a3NV4/22/)
I would like that daterangepicker to take 100% width like all other form elements, but can't get that to work.
My only workaround was to use datepicker css for bootstrap 2. I should use these rules:
#import url('http://getbootstrap.com/dist/css/bootstrap.css');
#import url('http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css');
but instead I'm using (there is missing 3 at end of second line):
#import url('http://getbootstrap.com/dist/css/bootstrap.css');
#import url('http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker.css');
this is what I get when I use bootstrap 3 css:
also on small screen inputs in picker don't have equal width:
I would like to switch entirely to bootstrap 3, but this tiny but is stopping me from doing so.
You could add the col-xs-12 class to your input-group. This will force the group to always be as wide as it's parent container.
<div class="form-group">
<label class="col-sm-3 control-label">Dates range</label>
<div class="col-sm-9">
<div class="input-daterange" id="datepicker">
<div class="input-group col-xs-12">
<input type="text" class="input-small form-control" name="start" />
<span class="input-group-addon">to</span>
<input type="text" class="input-small form-control" name="end" />
</div>
</div>
</div>
</div>
Updated Fiddle
The problem was datepicker custom .input-group-addon css.
.input-daterange .input-group-addon {
width: auto; /*remove this line*/
min-width: 16px;
padding: 4px 5px;
font-weight: normal;
line-height: 1.428571429;
text-align: center;
text-shadow: 0 1px 0 #fff;
vertical-align: middle;
background-color: #eeeeee;
border: solid #cccccc;
border-width: 1px 0;
margin-left: -5px;
margin-right: -5px;
}
after removing width: auto both bugs were fixed, please see: http://jsfiddle.net/Misiu/a3NV4/24/

css control alignment issue

I am trying to align label : control, label: control in 2 rows.
But text in my 2nd row moves to little bit right as below image. How can I align label and control in same line for second row also? These are generic forms so I dont want to add any height added to class. Any help would be highly appreciated.
Here is my Code
<div class="editor-label"><label for="DocumentSignature">This is a test label with big text below and below</label></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-required="The Document Signature Services Request URL field is required." id="DocumentSignature" name="DocumentSignature" type="text" value="">
<span class="field-validation-valid" data-valmsg-for="DocumentSignature" data-valmsg-replace="true"></span></div>
<div class="editor-label"><label for="DealSummary">This is next div text which moved to right</label></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-required="The Deal Summary Template URL field is required." id="DealSummary" name="DealSummary" type="text" value=""> <span class="field-validation-valid" data-valmsg-for="DealSummary" data-valmsg-replace="true"></span></div>
.editor-label {
max-width: 150px;
font-weight: 200;
font-size: 14pt;
letter-spacing: 0.01em;
line-height: 22pt;
float: left;
display: block;
}
.editor-field {
padding-bottom: 10px;
line-height: 22pt;
font-size: 10pt;
clear: right;
}
.label {
width: 180px;
display: block;
text-align: right;
margin-right: 15px;
}
Please see here for JsFiddle Demo
You have to wrap single row with one parent div and then clear all float at that div.
HTML:
<div class='single_row'>
<div class="editor-label"><label for="DocumentSignature">This is a test label with big text below and below</label></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-required="The Document Signature Services Request URL field is required." id="DocumentSignature" name="DocumentSignature" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="DocumentSignature" data-valmsg-replace="true"></span></div>
</div>
<div class='single_row'>
<div class="editor-label"><label for="DealSummary">This is next div text which moved to right</label></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-required="The Deal Summary Template URL field is required." id="DealSummary" name="DealSummary" type="text" value=""> <span class="field-validation-valid" data-valmsg-for="DealSummary" data-valmsg-replace="true"></span></div>
</div>
CSS:
.editor-label {
max-width: 150px;
font-weight: 200;
font-size: 14pt;
letter-spacing: 0.01em;
line-height: 22pt;
float: left;
display: block;
}
.single_row{ clear:both;}
.editor-field {
padding-bottom: 10px;
line-height: 22pt;
font-size: 10pt;
clear: right;
}
.label {
width: 180px;
display: block;
text-align: right;
margin-right: 15px;
}
Add a container that will contain both .editor-field and .editor-label. Without this, it will be very difficult if not impossible to make then work together.
<div class="editor-element">
<div class="editor-label">...</div>
<div class="editor-field">...</div>
</div>
Make this container "contain" the floated elements, so either add overflow: hidden, some kind of float or clearfix to it:
.editor-element {
overflow: hidden;
}
jsFiddle Demo

Applying CSS (via LESS) to modal box by ID does not work

I'm a new user to StackOverflow. Looking forward to be part of your wonderful community. My question is as follows:
I want to use a Twitter Bootstrap modal box on my website. However, I'm facing problems getting the CSS to work on the modal box. I wrote the following HTML code:
<div id="playModal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<span class="login"><strong>Login</strong></span>
</div>
<div class="modal-body">
<form class="form-horizontal" accept-charset="utf-8" method="post" action="#">
<fieldset>
<div class="control-group">
<label class="control-label" for="play_form_username">Username</label>
<div class="controls">
<input type="text" id="play_form_username" name="username" placeholder="Enter your username" required />
</div>
</div>
<div class="control-group">
<label class="control-label" for="play_form_password">Password</label>
<div class="controls">
<input type="password" id="play_form_password" name="password" placeholder="Enter your password" required />
</div>
</div>
</fieldset>
<span>Forgot your password?</span>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Play!</button>
</div>
</form>
</div>
<div class="modal-footer">
<span>Not a member yet? Join Now!</span>
<!--need to find a way to get this modal box to disappear if registerModal is called-->
</div>
</div>
Next, I want to configure the design of the page. I am using LESS to write code which is converted to CSS through SIMPLESS. I tried passing my desired CSS configuration through the modal div ID in the following LESS code:
#playModal{
width: 300px;
.modal-backdrop,
.modal-backdrop.fade.in{
opacity: 1;
filter: alpha(opacity=100);
}
.modal-header{
.login{
font-family: arial;
font-size: 60px;
font-weight: bolder;
}
}
.modal-body{
max-height: 200px;
}
}
This compiles successfully to CSS, but when I analyse the webpage using Firebug, it appears that none of the CSS has been passed for the modal box. Instead, if I use pass the CSS configurations by class, similar to the following, it works.
.modal{
width: 315px;
margin-left: 0px;
left: 50%;
top: 58px;
.modal-header{
padding: 7px 15px;
.login{
color: #203665;
font-size: 20px;
font-weight: bolder;
line-height: 24px;
}
}
}
Why is it that the CSS rules are not passed when referring to the modal box by ID? Isn't ID be more specific than class? Note: even when i use !important on the code using ID, it doesn't work.
It will be greatly appreciated if someone can help me out- though it's probably because I did something stupid. (The context why I need to use ID and not just class is: I'm needing to add a second modal box, and I want it to have different size, field sizes etc.) Thanks.
EDIT: (Answers my own silly question)
After dabbling around with the code, I found that the following works:
//Settings for all models
.modal-backdrop.fade.in{
opacity: 0.9!important;
filter: alpha(opacity=90)!important;
}
//Settings for playModal
#playModal{
width: 315px;
margin-left: 0px;
left: 50%;
top: 58px;
.modal-header{
padding: 7px 15px;
.login{
color: #203665;
font-size: 20px;
font-weight: bolder;
line-height: 24px;
}
}
.modal-body{
padding: 10px;
.control-group{
margin-bottom: 10px;
.control-label{
width: 65px;
text-align: left;
}
.controls{
margin-left: 75px;
}
}
span a{
display: block;
margin-top: 0px;
padding-top: 15px;
float: left;
&:hover{
text-decoration: none;
}
}
.form-actions{
display: block;
float: right;
margin: 0px;
padding: 0px;
border: 0px;
background-color: #FFFFFF;
.btn{
font-size: 18px;
line-height: 24px;
}
}
}
.modal-footer{
padding: 7px!important;
}
}
I think what I did wrong was to put the .modal-backdrop.fade.in inside the #playModal, it dawns on me now that .modal-backdrop.fade-in would be referring to the area outside of the #playModal div.
So all in all it was just a trivial mistake that got me worked up for so many hours. Sorry to waste everyone's time. What a way to start on StackOverflow. But anyway thanks everyone for trying to help me out. Please vote to close this post.
You're using the wrong case.
You give the element the id, playModal
Your css refers to #playmodal
Css is case-sensitive.

How do I center this form in css?

I have tried everything. I cannot get this centered on the screen. I am using ie 9 but it does the same in chrome. It just sits on the left of the webpage. Thank you for any help.
<style type="text/css">
body {
margin:50px 0px; padding:0px;
text-align:center;
align:center;
}
label,input {
display: block;
width: 150px;
float: left;
margin-bottom: 10px;
}
label {
text-align: right;
width: 75px;
padding-right: 20px;
}
br {
clear: left;
}
</style>
</head>
<body>
<form name="Form1" action="mypage.asp" method="get">
<label for="name">Name</label>
<input id="name" name="name"><br>
<label for="address">Address</label>
<input id="address" name="address"><br>
<label for="city">City</label>
<input id="city" name="city"><br>
<input type="submit" name="submit" id="submit" value="submit" class="button" />
</form>
</body>
Another way
body {
text-align: center;
}
form {
display: inline-block;
}
<body>
<form>
<input type="text" value="abc">
</form>
</body>
Wrap your form in a div.
Set the div's display to block and text-align to center (this will center the contained form).
Set the form's display to inline-block (auto-sizes to content), left and right margins to auto (centers it horizontally), and text-align to left (or else its children will be center-aligned too).
HTML:
<div class="form">
<form name="Form1" action="mypage.asp" method="get">
...
</form>
</div>
CSS:
div.form
{
display: block;
text-align: center;
}
form
{
display: inline-block;
margin-left: auto;
margin-right: auto;
text-align: left;
}
body { text-align: center; }
/* center all items within body, this property is inherited */
body > * { text-align: left; }
/* left-align the CONTENTS all items within body, additionally
you can add this text-align: left property to all elements
manually */
form { display: inline-block; }
/* reduces the width of the form to only what is necessary */
​
http://jsfiddle.net/sqdBr/4/
Works & tested in Chrome/IE/FF
You can try
form {
margin-left: 25%;
margin-right:25%;
width: 50%;
}
Or
form {
margin-left: 15%;
margin-right:15%;
width: 70%;
}
Try adding this to your css
.form { width:985px; margin:0 auto }
and add width:100% to the body tag
Then put:
<div class="form">
before the tag.
You can try this code for your 'body' tag, change it as you like..
body {
display: flex;
justify-content: center;
margin-top: 5%;
align-items: center;
}
i dont know if the full resolution has been made for this yet. i know that from doing a 2 column page with fixed left side bar, to get a contact us form centered on my page i put the following:
form {
width: 100%;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
this worked for me so thought id throw in my resolution to the same problem
This best solution I found online is using absolute positioning.
.login-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-49%, -49%);
}
You can use the following CSS to center the form (note that it is important to set the width to something that isn´t 'auto' for this to work):
form {
margin-left:auto;
margin-right:auto;
width:100px;
}
I css I got no idea
but I made that just by centering the form in html
something like this:
in css:
form.principal {width:12em;}
form.principal label { float:left; display:block; clear:both; padding:3px;}
form.principal input { float:left; width:8em;}
form.principal button{clear:both; width:130px; height:50px; margin-top:8px;}
then in html:
<center><form class="principal" method="POST">
<fieldset>
<p><label for="username">User</label><input id="username" type="text" name="username" />
<p><label for="password">Password</label><input id="password" type="password" name="password" /></p>
<button>Log in</button>
</fieldset>
</form></center>
This will center the form, and the content will be in the left of the centered form.
Normally, if you look up any software issue on stackoverflow, you quickly find a clear answer. But in CSS, even something as simple as "center a form" leads to a long discussion, and lots of failed solutions.
Correction: orfdorf's solution (above) works.
body {
text-align: center;
}
form {
width:90%;
background-color: #c0d7f8;
}
<body>
<form>
<input type="text" value="abc">
</form>
</body>
<!DOCTYPE html>
<html>
<head>
<title>Private</title>
<!-- local links -->
<style>
body{
background-color:#6e6969;
text-align:center;
}
body .form_wrapper{
display:inline-block;
background-color: #fff;
border-radius: 5px;
height: auto;
padding: 15px 18px;
margin: 10% auto;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<div class = "form_wrapper">
<form method="post" action="function.php">
<h1 class = "formHeading">Admin login form</h1>
<input type = "text" name = "username" id = "username"placeholder = "Enter Username" required = "required">
<input type = "password" name = "password" id = "password" placeholder = "Enter password" required = "required">
<button type = "submit" >Login</button>
froget password!
<span>?</span>help
</form>
</div>
</body>
</html>
Another solution (without a wrapper) would be to set the form to display: table, which would make it act like a table so it would have the width of its largest child, and then apply margin: 0 auto to center it.
form {
display: table;
margin: 0 auto;
}
Credit goes to: https://stackoverflow.com/a/49378738/7841955
I had the same problem (i use google)
What i did is i added the align attribute to the form
<form align="center">
<!--Stuff-->
</form>
That is one solution

Resources