HTML: Textbox and Select Dropdown are not level - html

I've been messing with this for a while now and I can simply not get the dropdown to be level with the textboxes! I've been changing the padding, margin, borders, height and all I can think of to make it be level both at the top and at the bottom.
What could be wrong?
.metricDateTextbox {
width: 130px;
padding: 11px;
border: 1px solid white;
color: transparent;
text-shadow: 0 0 0 black;
font-family: Verdana;
font-weight: 500;
background: #fff center right 10px no-repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAAjUlEQVR42rTTQQ6DIBBG4XcuOZlIMHri2gtMN2OKBAt05E/YsPheDBG+84DDPqfWZRsgwNsYcWqImgDseiHGiAOOzNoB5uzyn0gJF7W5ixyNkSqePnJvZGrFa5GpA/e1T14aInf40vpovyJmvBZ5PYGfCwUsP8H664eR+LlYwFceXhqJDFrsxkVk6PkMALMhvwVPjvl/AAAAAElFTkSuQmCC);
background-size: 12px 8px;
cursor: pointer;
user-select: none;
margin: 0;
}
::-webkit-input-placeholder {
color: grey;
font-weight: 500;
font-family: Verdana;
}
.dwmViewSelect {
width: 80px;
height: 40px;
top: -10px;
font-weight: bold;
border: 1px solid white;
margin: auto;
padding-top: unset 50px;
}
.showDateBtn {
width: auto;
padding: 10px;
text-align: center;
}
<form method="post" action="" name="form">
<div class="reportDateDiv">
<a class="blackColor fSize18">Reporting Period</a>
<input type="text" name="inputDate" spellcheck="false" class="datepicker metricDateTextbox capitalFirst" value="#inputDate" autocomplete="off" placeholder="#placeholderStartDate.ToString(" MMM d, yyyy ")" readonly="readonly" />
<a class="blackColor fSize16">to</a>
<input type="text" name="endDate" spellcheck="false" class="datepicker metricDateTextbox capitalFirst" value="#endDate" autocomplete="off" placeholder="#noEndDate.ToString(" MMM d, yyyy ")" readonly="readonly" />
<select name="hAxisType" class="dwmViewSelect">
<option selected=#(Request.Form[ "hAxisType"]=="1" ) value="1">Daily</option>
<option selected=#(Request.Form[ "hAxisType"]=="2" ) value="2">Weekly</option>
<option selected=#(Request.Form[ "hAxisType"]=="3" ) value="3">Monthly</option>
</select>
<input type="submit" value="Show" class="showDateBtn" />
</div>
</form>
See this fiddle as well!
https://jsfiddle.net/g6Ledf00/1/

Select element is a inline-block element, setting vertical-aling:top will align the element to the top,
here is some documentation
fiddle
.dwmViewSelect {
width: 80px;
height: 40px;
top: -10px;
font-weight: bold;
border: 1px solid white ;
margin: auto;
padding-top:unset 50px;
vertical-align: top;
}

Related

How to centralize content inside a form

Could someone help me? I am with this form trying to centralize all fields in it. I've tried a bunch of different stuff, and I've noticed that the code works differently inside the theme that I am using. Is there another way to do it rather than margin: 0 auto;? Any help will be really appreciated. Here is the url. Thank you
<div id="instant-quote-form">
<form action="http://natesolutions.vonigo.com/external/" accept-charset="UTF-8" method="get" onsubmit="return submitForm(this)">
<div class="instant-quote">
<h3 class="quote-title">Instant Online Quote</h3>
</div>
<div class="house-type">
<input type="radio" onclick="showServices(this)" id="xclientTypeID" name="xclientTypeID" value="1" checked />Residential
<input type="radio" onclick="showServices(this)" id="xclientTypeID" name="xclientTypeID" value="2" />Commercial
</div>
<div class="zip-code">
<input type="text" id="zip" name="zip" value="" placeholder="Enter Postal Code"/>
</div>
<div class="house-size" id="divServices1">
<select id="xserviceTypeID1" onchange="changeService(this)">
<option value="14" selected>Small House (1200-2000sq.ft)</option>
<option value="17">Medium House (2001-2800sq.ft)</option>
<option value="18">Large House (2801-3500sq.ft)</option>
<option value="19">XL House (3500+)</option>
</select>
</div>
<div class="button-go">
<input type="submit" value="Go" />
</div>
<input type="hidden" id="xserviceTypeID2" value="20" />
<input type="hidden" id="xserviceTypeID5" value="20" />
<input type="hidden" id="clientTypeID" name="clientTypeID" value="1" />
<input type="hidden" id="serviceTypeID" name="serviceTypeID" value="14" />
</form>
</div>
<style>
#instant-quote-form {
width: 100%;
margin: 0 auto;
}
.instant-quote {
float: left;
margin: 20px 5px;
padding-top: 4px;
}
.house-type {
float: left;
margin: 20px 5px;
color: #ffffff;
font-size: 16px;
padding-top: 5px;
}
.zip-code {
float: left;
margin: 20px 5px;
border: 1px solid #ffffff;
border-radius: 3px;
color: #000000;
}
.house-size {
float: left;
margin: 20px 5px;
border: 1px solid #ffffff;
border-radius: 3px;
color: #000000;
}
select#xserviceTypeID1 {
border: 1px solid #ffffff;
font-size: 13px;
padding: 10px;
color: #000000;
}
.button-go {
float: left;
margin: 20px 5px;
}
h3.quote-title {
margin-bottom: 0;
color: #ffffff;
}
input#zip {
margin-bottom: 0;
border: 1px solid #ffffff;
font-size: 13px;
padding: 9px;
}
input#zip::placeholder {
color: #000000;
}
input[type=text]::placeholder {
color: #000000;
}
input#xclientTypeID {
margin: 0 5px;
}
input[type="submit"] {
height: 37px;
width: 50px;
background: #55b948;
color: #fff;
border-radius: 3px;
text-transform: uppercase;
border: 1px solid #55b948;
font-weight: bold;
}
</style>
As your #instant-quote-form is as wide as its parent, centering this element will not do anything. What you will need to do is to center the <form> inside of its container. This can be done by applying display:flex to #instant-quote-form and then margin:0 auto to #instant-quote-form > form:
#instant-quote-form {
display: flex;
}
#instant-quote-form > form {
margin: 0 auto;
}
Try enclosing your <form> within <center> tag
Additionally, If you want the form with elements in a vertically aligned fashion then set float to none for each direct child of your <form>
If this isn't what you were looking for, please elaborate your issue and expected outcome.

Aligning search box to center

I picked a good css/html code for implementation of search box on the web. But I can't move the search box to center. The below css code is about search box.
#search {
width: 357px;
margin: 4px;
}
#search_text{
width: 297px;
padding: 15px 0 15px 20px;
font-size: 16px;
font-family: Montserrat, sans-serif;
border: 0 none;
height: 52px;
margin-right: 0;
color: white;
outline: none;
background: #1f7f5c;
float: left;
box-sizing: border-box;
transition: all 0.15s;
}
<li id="search">
<form action="" method="get">
<input type="text" name="search_text" id="search_text" placeholder="Search"/>
<input type="button" name="search_button" id="search_button"/>
</form>
</li>
What should I fix the code for aligning the search box?
Thanks.
Try providing text-align: center to your body.
Refer code:
body {
text-align: center;
}
#search {
width: 357px;
margin: 4px auto;
text-align: center;
display: inline-block;
}
#search_text {
width: 297px;
padding: 15px 0 15px 20px;
font-size: 16px;
font-family: Montserrat, sans-serif;
border: 0 none;
height: 52px;
margin-right: 0;
color: white;
outline: none;
background: #1f7f5c;
float: left;
box-sizing: border-box;
transition: all 0.15s;
}
<li id="search">
<form action="" method="get">
<input type="text" name="search_text" id="search_text" placeholder="Search" />
<input type="button" name="search_button" id="search_button" />
</form>
</li>
If you want to align the text in the center of the textbox than use #nashcheez answer.
If you want to align the searchbox itself to the center of the parent than:
Set the textbox to display block
Give a with to the textbox
Set margin-left to auto
Set margin-right to auto
You may have to set position to relative.
you can try to use:
#search {
width: 357px;
margin-right: auto;
margin-left: auto;
}
if its being overridden, try using:
#search {
width: 357px;
margin-right: auto !important;
margin-left: auto !important;
}
If li#search is all you've got, try this:
#search {
width: 357px;
margin: 4px auto;
}
#search_text{
width: 297px;
padding: 15px 0 15px 20px;
font-size: 16px;
font-family: Montserrat, sans-serif;
border: 0 none;
height: 52px;
margin-right: 0;
color: white;
outline: none;
background: #1f7f5c;
float: left;
box-sizing: border-box;
transition: all 0.15s;
}
<li id="search">
<form action="" method="get">
<input type="text" name="search_text" id="search_text" placeholder="Search"/>
<input type="button" name="search_button" id="search_button"/>
</form>
</li>

Fields will not float left

I am a newbie, I am having a frustrating problem. 2 out of 8 of my text fields will not float left, even though they are using the same or similar script as the other other fields. It is very frustrating, as you can see below:
/*franchise details form container*/
div#section_left{
padding: 0;
position:absolute;
width: 76%;
height: 100%;
float: right;
margin-top: 60px;
margin-left: 310px;
padding-left: 10px;
padding-right: 10px;
padding-top: 30px;
}
div.field{
position: relative;
}
/*Form fields styling*/
/* red box*/
div.field,
div.field:before,
div.field input#fran_name,
input#fran_email,input#mang_name,
input#address1, input#franc_phone{
height: 33px;
padding: 0;
border-width: 0;
/* remove default border */
}
div.field input#fran_name,
input#fran_email,input#mang_name,
input#address1, input#franc_phone{
border: 1px solid #6d6e70;
border-left: 0px;
padding-left: 5px;
border-radius: 0 5px 5px 0;
width: 40%;
margin-bottom: 10px;
}
div.field:before{
content: "\f015";
width: 30px;
height: 30px;
border: 1px solid #e86065;
display: inline-block;
float: left;
position: relative;
background: #e86065;
color: white;
text-align: center;
line-height: 33px;
border-radius: 5px 0 0 5px;
}
div.field1:before{
content: "\0260E";
width: 30px;
height: 30px;
border: 1px solid #e86065;
display: inline-block;
float: left;
position: relative;
background: #e86065;
color: white;
text-align: center;
line-height: 33px;
border-radius: 5px 0 0 5px;
}
div.field2:before{
content: "\0260E";
width: 30px;
height: 30px;
border: 1px solid #e86065;
display: inline-block;
float: left;
position: relative;
background: #e86065;
color: white;
text-align: center;
line-height: 33px;
border-radius: 5px 0 0 5px;
}
div.field3:before{
content: "\0260E";
width: 30px;
height: 30px;
border: 1px solid #e86065;
display: inline-block;
float: left;
position: relative;
background: #e86065;
color: white;
text-align: center;
line-height: 33px;
border-radius: 5px 0 0 5px;
}
div.field4:before{
content: "\0260E";
width: 30px;
height: 30px;
border: 1px solid #e86065;
display: inline-block;
float: left;
position: relative;
background: #e86065;
color: white;
text-align: center;
line-height: 33px;
border-radius: 5px 0 0 5px;
margin-top: 55px;
}
div.field4 input#franc_phone{
margin-top: 55px;
}
input#address2,input#city {
border: 1px solid #6d6e70;
border-radius: 5px;
width: 43%;
height: 33px;
display: inline-block;
line-height: 33px;
float: left;
position: relative;
margin-bottom: 10px;
}
input#pcode{
border: 1px solid #6d6e70;
border-radius: 5px;
width: 20%;
height: 33px;
line-height: 33px;
float: left;
position: relative;
margin-top: 10px;
margin-bottom: 10px;
}
.clr{
clear: both;
}
<div id="section_left">
<form id="franchiseDets" action ="Franchise-Details.php" method="POST">
<div class="group1">
<!-- franchise details form-->
<div class="field">
<input type="text" name="fran_name" id="fran_name" value="<?php echo $_SESSION['fran_name']; ?>" placeholder="e.g One Delivery Leeds" pattern="[a-zA-Z]"
autofocus required tabindex="1"></div>
<br>
<div class="field1">
<input type="email" name="fran_email" id="fran_email" value="<?php echo $_SESSION['fran_email'] ?> ' <?php echo $disabled ?>" placeholder="leeds#one-delivery.co.uk" required tabindex="2">
</div>
<br>
<div class="field2">
<input type="text" name="mang_name" id="mang_name" value="<?php echo $_SESSION['mang_name']; ?>" placeholder="Joe Blogs" required tabindex="3">
</div>
<br>
<div class="field3">
<input type="text" name="address1" id="address1" value="<?php echo $_SESSION['address1']; ?>" placeholder="Address Line 1" tanindex="4">
</div>
<br>
<input type="text" name="address2" id="address2" value="<?php echo $_SESSION['address2']; ?>" placeholder="Address Line 2" tabindex="5">
<br>
<br>
<input type="text" name="city" id="city" value="<?php echo $_SESSION['city']; ?>"placeholder="Town/City" tabindex="6">
<br>
<br>
<input type="text" name="pcode" id="pcode" value="<?php echo $_SESSION['pcode']; ?>" placeholder="Postcode" tabindex="7">
<br>
<div class="field4">
<input type="tel" name="franc_phone" id="franc_phone" value="<?php echo $_SESSION['franc_phone'] ?>" placeholder="Customer service number" min="10" maxlength="11" pattern="[0-9]{3}[-][0-9]{4}[-][0-9]{4}"
required title="Please provide your customer service number in the following format: 000-0000-0000" tabindex="8"> </div>
</div>
<br>
</div>
</div>
</form>
The divs wrapped the forms are the only way the red box in the css works, i have also removed them to see if they are the reason for the problem and they weirdly are not.
What can i do to resolve this
If you're looking to have all you're text boxes align on the left, that's not floating left. Looking at the example image, the only two elements that look to be properly floating left are 2 which are offset from the left. Try removing all left floats from your css and set the body text-align property to left.
body {
text-align: left;
}
All the other inputs are wrapped in a DIV element - wrap the rest in DIV as well and it should work.

How to style the DIV to display html controls

I have the following HTML:
<div class="dispLoginSearch" style="text-align: left; overflow: hidden;"> <!-- LOGIN AND SEARCH -->
<div class="theLoginBox" style="clear: both;">
<div class="loginTitle">
Log in to <span style="font-family: 'blackjarregular'; font-size: 14pt; color: #FE7816;">My</span> <span style="font-family: 'trajanpro'; font-size: 12pt; color: #00529B;">WD</span> | Sign Up
<br />
<input type="text" value="Username" /> <input type="password" value="Password" /> <input type="button" value="Go" />
<br />
<span style="float: right;">Forgot login/password</span>
</div>
</div>
<div style="z-index: 99999999999;">
<input type="text" value="Search WD" />
</div>
</div> <!-- LOGIN AND SEARCH -->
CSS:
.dispLoginSearch
{
width: 47%;
height: 150px;
line-height: 150px;
vertical-align: middle;
float: right;
padding-right: 2%;
background: #FFFFFF;
border: 1px solid #0026ff;
}
.theLoginBox
{
border: 2px solid #D5D5D5;
border-radius: 4px;
width: 97%;
height: 90px;
padding: 10px;
white-space: nowrap;
background: #ff6a00;
}
.loginTitle
{
height: 88px;
display: block;
vertical-align: top;
white-space: nowrap;
font-weight: bold;
text-align: left;
background: #b6ff00;
}
When I view the website, I see the following:
What I would like it be shown:
How do I fix the issue? It is happening in both IE and other browsers.
UPDATE:
I added overflow: auto in the loginTitle class and this is what is shown:
Each section is taking up a lot of space and showing the scrollbar :/
This is because of line 5 of your CSS : line-height: 150px;.
Just remove it and you should be fine.
If you want it to look like image you attached, see here: http://codepen.io/anon/pen/FothH
html:
<form action="#">
<p>Log in to ###### | Sign up</p>
<input type="text" placeholder="Username"/>
<input type="password" placeholder="Password"/>
<input type="submit" value="Go"/>
Forgot login/password
</form>
css:
form {
border: 1px solid #d4d4d4;
display: block;
width: 375px;
font: 16px sans-serif;
padding: 0 0 0 15px;
border-radius: 5px;
-webkit-font-smoothing: antialiased;
}
form p {
margin: 5px 0 0;
font-size: 20px;
line-height: 35px;
}
input {
display: inline-block;
border-radius: 7px;
}
input[type=text], input[type=password] {
border: none;
background: #ebebeb;
font-size: 16px;
padding: 6px 10px;
width: 180px;
}
input[type=password] {
width: 120px;
}
input[type=submit] {
font-size: 16px;
width: 25px;
padding: 5px 0px;
background: none;
color: red;
border: none;
}
form a {
display: block;
line-height: 25px;
text-align: right;
margin-right: 30px;
color: #d4d4d4;
text-decoration: none;
margin-bottom: 5px;
}

Text input box side by side not aligning in css3

I require 2 text input boxes side by side in one page using css3. I have everything ready except that the second box is coming below the first input box. How can i correct this in css.
html:
<div class="main">
<div class="one">
<div class="register">
<h3>Create your account</h3>
<form id="reg-form">
<div>
<div>
<label for="username">Username</label>
<input type="text" id="username" spellcheck="false" placeholder="User Name" />
</div>
<div>
<label for="password">Password</label>
<input type="password" id="password" />
</div>
<div>
<label></label>
<input type="submit" value="Shop Login" id="create-account" class="button"/>
</div>
</form>
</div>
</div>
<div class="two">
<div class="register">
<h3>Create your account</h3>
<form id="reg-form1">
<div>
<label for="name1">Name</label>
<input type="text" id="name1" spellcheck="false" placeholder="Enter Your Name"/>
</div>
<div>
<label for="email1">Email</label>
<input type="text" id="email1" spellcheck="false" placeholder="mymail#mail.com"/>
</div>
<div>
<label for="username1">Username</label>
<input type="text" id="username1" spellcheck="false" placeholder="User Name" />
</div>
<div>
<label for="password1">Password</label>
<input type="password" id="password1" />
</div>
<div>
<label for="password-again1">Password Again</label>
<input type="password" id="password-again1" />
</div>
<div>
<label></label>
<input type="submit" value="Create Account" id="create-account1" class="button"/>
</div>
</form>
</div>
</div>
</div>
CSS
.main > div {
display: inline-block;
width: 49%;
margin-top: 10px;
}
.two .register {
border: none;
}
.two .register h3 {
border-bottom-color: #909090;
}
.two .register .sep {
border-color: #909090;
}
.register {
width: 400px;
margin: 10px auto;
padding: 10px;
border: 7px solid #ADD8E6;
border-radius: 10px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #444;
background-color: #f0f0f0;
box-shadow: 0 0 20px 0 #000000;
}
.register h3 {
margin: 0 15px 20px;
border-bottom: 2px solid #72b372;
padding: 5px 10px 5px 0;
font-size: 1.1em;
}
.register div {
margin: 0 0 15px 0;
border: none;
}
.register label {
display: inline-block;
width: 25%;
text-align: right;
margin: 10px;
}
.register input[type=text], .register input[type=password] {
width: 65%;
font-family: "Lucida Grande","Lucida Sans Unicode",Tahoma,Sans-Serif;
padding: 5px;
font-size: 0.9em;
border-radius: 5px;
background: rgba(0, 0, 0, 0.07);
}
.register input[type=text]:focus, .register input[type=password]:focus {
background: #FFFFFF;
}
.register .button {
font-size: 1em;
border-radius: 8px;
padding: 10px;
border: 1px solid #ADD8E6;
box-shadow: 0 1px 0 0 #05B8CC inset;
background: #05B8CC;
background: -webkit-linear-gradient(#ADD8E6, #05B8CC);
background: -moz-linear-gradient(#ADD8E6, #05B8CC);
background: -o-linear-gradient(#ADD8E6, #05B8CC);
background: linear-gradient(#ADD8E6, #05B8CC);
}
.register .button:hover {
background: #51db1c;
background: -webkit-linear-gradient(#51db1c, #6ba061);
background: -moz-linear-gradient(#51db1c, #6ba061);
background: -o-linear-gradient(#51db1c, #6ba061);
background: linear-gradient(#51db1c, #6ba061);
}
.register .sep {
border: 1px solid #72b372;
position: relative;
margin: 35px 20px;
}
.register .or {
position: absolute;
width: 50px;
left: 50%;
background: #f0f0f0;
text-align: center;
margin: -10px 0 0 -25px;
line-height: 20px;
}
.register .connect {
width: 400px;
margin: 0 auto;
text-align: center;
}
I have provided a jsFiddle Demo
I require it aligned side by side rather than top bottom as in demo. Thanks in advance
You have missed a closing div before <div class="two">.
Adding the closing div will make both forms next to each other.
Then you need to add a little CSS rule to make both forms perfectly aligned vertically:
div.one {
position: relative;
top: -165px
}
See the demo here: http://jsfiddle.net/t5SNE/7/