Inconsistent heights with date and select - html

I have come across this issue and not sure of resolution. These 2 inputs should be coming in exactly the same height, however they are not. After looking at similar questions exhaustively, I've confirmed this is not due to box-sizing. Any thoughts or help would be greatly appreciated.
This is the issue in question:
.updateInput select {
width: calc(24.5% - 4px);
min-height: 1.5em;
}
select {
width: 100%;
border: 1px solid #ccc;
border-radius: 10px;
background-color: white;
margin-top: 10px;
margin-bottom: 10px;
padding: 0.5em;
font-size: 16px;
font-family: Courier, Arial, Helvetica, sans-serif;
cursor: pointer;
line-height: 14px;
min-height: 1.5em;
}
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.updateInput input[type=date] {
width: calc(24.5% - 4px);
}
input[type=number],
input[type=date] {
width: 100%;
border: 1px solid #ccc;
border-radius: 10px;
background-color: white;
margin-top: 10px;
margin-bottom: 10px;
font-size: 16px;
font-family: Courier, Arial, Helvetica, sans-serif;
cursor: pointer;
line-height: 14px;
}
input {
font: inherit;
vertical-align: middle;
padding: 0.5rem;
margin: 0;
display: inline-block;
min-height: 1.5em;
}
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<div id="saleUpdateInput" class="updateInput">
<form id="updateInputData">
<select>
<option selected>Select product</option>
</select>
<select>
<option selected>Select sale %</option>
</select>
<input type="date">
<input type=submit value="Update">
</form>
</div>
Minimal example as requested in comments:
https://jsfiddle.net/8qexLpa3/

You will notice by default display:inline-block aligns selects to the top of the container and inputs to the bottom.
<div id="saleUpdateInput" class="updateInput">
<form id="updateInputData">
<select>
<option selected>Select product</option>
</select>
<select>
<option selected>Select sale %</option>
</select>
<input type="date">
<input type=submit value="Update">
</form>
</div>
I would recommend you use flex box to take control over this behavior.
#updateInputData {
display: flex;
}
<div id="saleUpdateInput" class="updateInput">
<form id="updateInputData">
<select>
<option selected>Select product</option>
</select>
<select>
<option selected>Select sale %</option>
</select>
<input type="date">
<input type=submit value="Update">
</form>
</div>

Related

How to fit inputs inside fieldset

my <input type=text> are longer then <select> tags. How do I make inputs have the same width as selects?
form fieldset {
width: 50%;
margin: auto;
border: 3px solid grey;
padding: 10px;
}
form fieldset legend {
font-size: 20px;
font-weight: bold;
}
form label {
font-weight: bold;
font-size: 16px;
margin-top: 10px;
}
form input, select {
margin-bottom: 10px;
padding: 5px;
border: 0;
border-bottom: 1px solid grey;
font-size: 16px;
width: 100%;
font-family: 'Poppins';
}
form input[type=submit] {
font-size: 20px;
border: 0;
font-weight: bold;
margin-top: 10px;
}
form input:focus, select:focus {
outline: none;
border-bottom: 2px solid black;
}
form div.submit {
width: 20%;
margin-left: auto;
margin-right: auto;
}
<!DOCTYPE html>
<html lang='cs'>
<head>
<meta charset='UTF-8'>
<title>Title</title>
</head>
<body>
<form method='POST' action='quotation.php?a=insert'>
<fieldset>
<legend>My legend</legend>
<label for='customer'>Customer: </label><br>
<select name='customer' id='customer'>
<option value='NULL'></option>
<option value='1'>Cust. 1</option>
<option value='2'>Cust. 2</option>
<option value='3'>Cust. 3</option>
</select><br>
<label for='contact_person'>Contact person: </label><br>
<select name='contact_person' id='contact_person'>
<option value='NULL'></option>
<option value='1'>CP 1</option>
<option value='2'>CP 2</option>
<option value='3'>CP 3</option>
</select><br>
<label for='project'>Project: </label><br>
<input type='text' name='project' id='project'><br>
<label for='part'>Part: </label><br>
<input type='text' name='part' id='part'><br>
<label for='recieved'>Recieved: </label><br>
<input type='date' name='recieved' id='recieved'><br>
<label for='deadline'>Deadline: </label><br>
<input type='date' name='deadline' id='deadline'><br>
<div class='submit'>
<input type='submit' value='Save'>
</div>
</fieldset>
</form>
</body>
</html>
Thank you for any idea.
I tried to set padding of whole fieldset:
fieldset { padding: 5px }
This is correct with tag but doesn't work with .
Then I tried to set: input {margin: 5px} but this didn't work as well. In the chrome DevTools i see that the margin is ouside of the fieldset area.
Because of padding, the border overflows the box so keep the top and bottom 5px and add 0 for right and left.
form input, select {
margin-bottom: 10px;
padding: 5px 0;
border: 0;
border-bottom: 1px solid grey;
font-size: 16px;
width: 100%;
font-family: 'Poppins';
}
Just update css style.
form input, select{
padding: 5px 0;}
I added this into CSS:
form input, select {
box-sizing: border-box;
}
This resolved my issue.

CSS code for select option tag

I have an form in my index page where i used same css code for input and select but the problem is that in input tag its working fine as per i want but in the select tag firstly width became little small and in when i am selecting the option its not getting selected though in MAC chrome its working fine but in windows chrome its not getting selected!!
Please check my code and let me know where i went wrong!
#contact-form input[type="text"],
#contact-form select[type="text"],
#contact-form textarea {
width: 247px;
max-width: 100%;
padding: 16px 10px;
background: #4f5662;
border: 1px solid #828fac;
border-radius: 5px;
-webkit-border-radius: 5px;
box-sizing: content-box;
-moz-border-radius: 5px;
-o-border-radius: 5px;
color: #b6b7b8;
font-size: 14px;
font-family: helvetica;
box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
-o-box-shadow: none;
margin-right: 18px;
}
#contact-form input[type="submit"],
.newsleter-widget input[type="submit"] {
float: right;
font-size: 14px;
color: #fff;
font-family: 'Noto Sans', sans-serif;
text-transform: uppercase;
background: #8248ac;
padding: 20px 13px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
border: none;
}
#contact-form input[type="text"],
#contact-form select[type="text"],
#contact-form2 textarea {
margin-right: 0;
display: block;
width: 94%;
max-width: 94%;
margin-bottom: 19px;
padding: 16px 3%
}
#contact-form textarea,
#contact-form2 textarea {
height: 110px;
padding: 8px 3%;
}
#contact-form input[type="submit"],
#contact-form2 input[type="submit"] {
display: block;
float: right;
padding: 20px 38px;
}
<div class="span4">
<h3>Contact Form</h3>
<form id="contact-form">
<input type="text" name="name" class="name" placeholder="Name">
<input type="text" name="email" class="email" placeholder="Email address">
<input type="text" name="email" class="email" placeholder="Phone no">
<select type="text" name="service">
<option value="" selected >Select Services</option>
<option value="" >Option 1</option>
<option value="" >Option 2</option>
<option value="" >Option 3</option>
</select>
<input type="submit" name="submit-form" id="submit" value="Send Message">
</form>
</div>
When i pasted code here also , the option tag is getting selected though but in my code its not getting selected!! but still here also width of the select tag is still little smaller as compared to input tag.
Now its looks like this
You must use box-sizing property to what should be included in sizing properties (width and height)
For your issue box-sizing: border-box and some modification in width and margin property will do the task.
Here is the fiddle for same https://jsfiddle.net/c7Lojau2/

Responsive Select Dropdwon option showing as black rectangular box in desktop Chrome browser mobile view

When I am testing my responsive HTML pages in cross browser compatibility, Am facing select drop down options problem in Chrome browser it's showing blank black rectangular as per the attachment.
HTML
<body>
<div class="container">
<div class="select-wrapper">
<select class="select" >
<option value="1" selected="selected">Option Number 1</option>
<option value="2">A Much Longer Option Than Option 1</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="4">Option 4</option>
</select>
<span class="select-icon entypo-arrow-combo"></span>
</div>
</div>
</body>
CSS
#import "compass/css3";
#import url(http://weloveiconfonts.com/api/?family=entypo);
[class*="entypo-"]:before {
font: 1.4em 'entypo', sans-serif;
}
/// Styles/
body {
background: #fafafa;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #333;
`}
.container {
margin: 5em auto 0;
width: 25%;
}
.select-wrapper {
background-color: #eee;
border: 1px solid #aaa;
color: #aaa;
cursor: pointer;
float: left;
overflow: hidden;
padding-right: 3em;
position: relative;
width: 100%;
}
.select {
-webkit-appearance: none;
background-color: #eee;
border-width: 0;
box-sizing: border-box;
cursor: pointer;
float: left;
font-size: 1em;
line-height: 1em;
padding: 1em 1em;
width: 100%;
width: calc(100% + 2em);
&:focus {
outline: none;
}
}
.select-icon {
position: absolute;
top: .8em;
right: 1em;
}
Finally got a solution : I'm using Google Chrome version 53.0.2785.143m after updating Chrome(Version 54.0.2840.59 m) It's working fine.

Align all types of html input

I am currently trying to finish up a little exercise I did. I am trying to align both my text input and my select input boxes, but I can't seem to figure out how to align the select list to the input box. I have tried using labels and css, and tables, but somehow my forms end up scattered across each other. Any help is greatly appreciated:
<!DOCTYPE html>
<html>
<head>
<title>Game Intro</title>
<link rel="stylesheet" type="text/css" href="http://localhost/webtech/sample.css"
</head>
<body>
<h1>Character Creation</h1>
<h2>You have 10 Gold Pieces</h2>
<ul>
<li>1 gold piece buys 10 health tokens</li>
<li>1 gold piece buys 2 experience tokens</li>
<li>1 gold piece buys 10 supply tokens</li>
</ul>
<form action="gameIntro.php" method="post">
<table>
<p>Enter your character's name:
<input type="text" size="20" name="character_name" /></p>
<p>Select your character class:
<select name="character_class">
<option>Dwarf</option>
<option>Human</option>
<option>Elf</option>
<option>Wizard</option>
</select>
</p>
<p>Purchase health tokens:
<select name="health_token">
<option>0</option>
<option>10</option>
<option>20</option>
<option>30</option>
</select>
</p>
<p>Purchase experience tokens:
<select name="experience_token">
<option>0</option>
<option>2</option>
<option>4</option>
<option>6</option>
<option>8</option>
<option>10</option>
</select>
</p>
<p>Purchase supply tokens:
<select name="supply_token">
<option>0</option>
<option>25</option>
<option>50</option>
<option>75</option>
<option>100</option>
</select>
</p>
<p><input type="submit" value="Submit your Character" />
<input type="reset" value="Reset your Character" /></p>
</table>
</form>
<a href={"http://localhost/index.html"}>Go back to Homepage</a>
</body>
</html>
css file:
body { background: white }
h1 { font-family: Arial, Helvetica, Sans-Serif;
font-size: 18pt; color: black; font-weight: bold; }
h2 { font-family: Arial, Helvetica, Sans-Serif;
font-size: 16pt; color: black; font-weight: bold; }
p { font-family: Arial, Helvetica, Sans-Serif;
font-size: 12pt; color: black; font-weight: bold; }
p.alert { font-style: italic; color: red; }
table { font-family: Arial, Helvetica, Sans-Serif;
font-size: 12pt; color: black; }
td.center { text-align: center; }
select { font-family: Arial, Helvetica, Sans-Serif;
font-size: 10pt; font-weight: bold; color: blue;
background: lightBlue; }
option { font-family: Arial, Helvetica, Sans-Serif;
font-size: 10pt; color: black; background: silver; }
Thx guys!
I would suggest you learn to use a table properly. Tables are not stand alone elements, there are certain required child elements. for example
<table>
<tr>
<td>Name: </td>
<td><input type="text" name="name" /></td>
</tr>
</table>
Start with reviewing how tables work, and you'll find this much easier.
http://www.w3schools.com/html/html_tables.asp
Here you go:
Use this HTML structure: Put your label/p elements on first column, input and select elements on second column.
<tr>
<td></td>
<td></td>
</tr>
Fiddle
As far as my knowledge - at this date... this is how I would mark up this form.
I only put the id's and for="" on the first input. I hope this helps you understand a bit better. Here is a fiddle - (change the browser window to see how the form adjusts for screen sizes)
HTML
<form action="gameIntro.php" method="post" class="character-form">
<ul>
<li>
<label for="input-name">Enter your character's name:</label>
<input id="input-name" type="text" size="20" name="character_name" />
</li>
<li>
<label>Select your character class:</label>
<select name="character_class">
<option>Dwarf</option>
<option>Human</option>
<option>Elf</option>
<option>Wizard</option>
</select>
</li>
<li>
<label>Purchase health tokens:</label>
<select name="health_token">
<option>0</option>
<option>10</option>
<option>20</option>
<option>30</option>
</select>
</li>
<li>
<label>Purchase experience tokens:</label>
<select name="experience_token">
<option>0</option>
<option>2</option>
<option>4</option>
<option>6</option>
<option>8</option>
<option>10</option>
</select>
</li>
<li>
<label>Purchase supply tokens:</label>
<select name="supply_token">
<option>0</option>
<option>25</option>
<option>50</option>
<option>75</option>
<option>100</option>
</select>
</li>
</ul>
<input type="submit" value="Submit your Character" />
<input type="reset" value="Reset your Character" />
</form>
CSS
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
/* look it up */
}
.character-form {
border: 1px solid red;
overflow: hidden; /* should be a clearfix */
}
.character-form ul {
width: 100%;
float: left;
list-style: none;
margin: 0; padding: 0;
}
.character-form li {
width: 100%;
float: left;
margin-bottom: 1em;
border: 1px solid blue;
}
.character-form li label {
border: 1px solid orange;
}
.character-form li input, .character-form li select {
border: 1px solid green;
width: 100%;
display: block;
float: left;
float: left;
}
#media (min-width:20em) {
.character-form {
max-width: 30em;
margin-right: auto;
margin-left: auto;
}
.character-form li label {
float: none;
width: auto;
vertical-align: middle;
display: inline-block;
min-width: 15em;
}
.character-form li input, .character-form li select {
float: none;
width: auto;
display: inline-block;
vertical-align: middle;
}
.character-form li input {
width: 100%;
max-width: 20em;
}
.character-form li select {
min-width: 12em;
}
} /* end break-point */

CSS & Form issue - giving me strife :( [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have created a form and it is supposed to look like this:
Can someone please help me edit my code to look like the above image and explain what I was doing wrong? A JSFiddle would be amazing so I can understand how to fix it.
The zip label and field needs to be brought up and the submit button pushed to the right, yet it's not working for me :(
My attempt is as follows:
http://jsfiddle.net/2w6mK/
CSS:
#form-container {
width: 710px;
height: 450px;
padding: 20px 50px;
margin: 35px 0 0 25px;
}
form {
position: relative;
margin-left: -10px;
}
form label {
display: block;
font: normal 12px/16px arial, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #000;
text-transform: uppercase;
text-align: left;
}
form [type="text"],
form [type="email"] {
display: block;
border: 1px solid #000;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font: 12px/14px arial, helvetica, verdana, sans-serif;
width: 60%;
padding: 5px 5px;
margin: 5px 0;
-webkit-appearance: none;
}
.zip {
display: block;
border: 1px solid #000;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font: 12px/14px arial, helvetica, verdana, sans-serif;
width: 20%;
padding: 5px 5px;
margin: 5px 0;
-webkit-appearance: none;
}
.dob-select {
display: block;
border: 1px solid #000;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font: 12px/14px arial, helvetica, verdana, sans-serif;
width: 80px;
height:25px;
-webkit-appearance: none;
overflow: hidden;
background: url("http://s17.postimage.org/4tmf81arf/down_arrow.png") no-repeat right #fff;
float: left;
margin-right: 5px;
}
.dob-select select {
background: transparent;
width: 125px;
height: 25px;
border: none;
padding: 5px 0 0 5px;
color: #cccccc;
}
.left {
float: left;
}
form [type="submit"] {
display: block;
background-image: url("http://findmuck.files.wordpress.com/2012/06/green_submit_button_by_rukiaxichigo15.jpg") no-repeat;
margin: 25px auto;
width: 154px;
height:57px;
border: none;
color: transparent;
font-size: 0;
float: left;
}
form input[type=submit]:hover {
background-image: url("http://findmuck.files.wordpress.com/2012/06/green_submit_button_by_rukiaxichigo15.jpg") no-repeat;
cursor: hand;
cursor: pointer;
}
#FileUpload {
position:relative;
margin-top: -13px;
padding-bottom: 15px;
}
#BrowserVisible {
position: absolute;
top: 0;
left: 0;
z-index: 1;
background:url(images/btn_browse.gif) 100% 0px no-repeat;
height:27px;
width:390px;
cursor: hand;
cursor: pointer;
}
#FileField {
display: block;
margin-right: 85px;
border: 1px solid #000;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font: 12px/14px arial, helvetica, verdana, sans-serif;
color: #777;
width: 300px;
padding: 5px 5px;
-webkit-appearance: none;
}
HTML:
<div id="form-container">
<form>
<fieldset>
<label for="name">Name</label>
<input type="text" name="name">
</fieldset>
<fieldset>
<label for="dob">date of birth</label>
<div class="dob-select">
<select name="dob_day">
<option value="01">01</option>
</select>
</div>
<div class="dob-select">
<select name="dob_month">
<option value="01">Jan</option>
</select>
</div>
<div class="dob-select">
<select name="dob_year">
<option value="2012">2012</option>
</select>
</div>
</fieldset>
<fieldset>
<label for="zip">zip</label>
<input type="text" class="short" name="zip">
</fieldset>
<fieldset>
<label for="email">Email</label>
<input type="email" name="email">
</fieldset>
<fieldset>
<label for="subscribe"><input type="checkbox" class="left"> <p class="left">Tick</p></label>
<input type="submit" name="submit">
</fieldset>
</form>
</div>
EDIT 2:
Add
.short{
width: auto !important;
}
to CSS to draw the ZIP field with full lenght as in picture.
EDIT: remove border: 1px solid silver; when you have understood how positioning is working, it's for debug purpose ;)
Look at: http://jsfiddle.net/pb6mM/3/
form input[type="submit"]{
position: absolute;
right: 0;
bottom: 0;
}
fieldset{
border: 1px solid silver;
}
.fieldsetDate{
padding-right: 30px;
}
.inlineBlock{
display: inline-block;
}
And added
margin-top: 6px;
margin-bottom: 6px;
to .dob-select { to make it the same height of the normal text field.
HTML:
<div id="form-container">
<form>
<fieldset>
<label for="name">Name</label>
<input type="text" name="name">
</fieldset>
<fieldset class="fieldsetDate inlineBlock">
<label for="dob">date of birth</label>
<div class="dob-select">
<select name="dob_day">
<option value="01">01</option>
</select>
</div>
<div class="dob-select" >
<select name="dob_month">
<option value="01">Jan</option>
</select>
</div>
<div class="dob-select">
<select name="dob_year">
<option value="2012">2012</option>
</select>
</div>
</fieldset>
<fieldset class="inlineBlock">
<label for="zip">zip</label>
<input type="text" class="short" name="zip">
</fieldset>
<fieldset>
<label for="email">Email</label>
<input type="email" name="email">
</fieldset>
<fieldset>
<label for="subscribe"><input type="checkbox" class="left"> <p class="left">Tick</p></label>
<input type="submit" name="submit">
</fieldset>
</form>
</div>
Add Position:absolute to input button. and there is slight changes in the html code. Check the demo.
DEMO
SAMPLE CSS FORM