Two inputs without space [duplicate] - html

This question already has answers here:
How to remove the space between inline/inline-block elements?
(41 answers)
Closed 5 years ago.
I just created a mailchimp form for my website and want to change the design. But between the email input and the button is a little white empty space. I played already a lot with the css code but I can't fix it by myself. I think it's not a big change but I don't get it correct.
Can you guys help me to remove the space and let me know, where is the issue in my code?
Thanks,
Chris
#mce-EMAIL {
display: inline-block;
padding: 8px 0;
width: 70%;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 1em;
color: #343434;
padding: .7em 9em .7em 2em;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
background-color: rgb(240, 240, 240);
background-image: none;
background-repeat: repeat;
background-attachment: scroll;
background-clip: border-box;
background-origin: padding-box;
background-position-x: 0%;
background-position-y: 0%;
background-size: auto auto;
font-family: "Arial" inherit;
color: #737373;
letter-spacing: 1px;
text-indent: 5%;
border-radius: 5px 0 0 5px;
border-top-left-radius: 5px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 5px;
opacity: 0.9;
border-style: solid;
border: none;
}
/* Input Styles */
.button {
clear: both;
display: inline-block;
width: 25%;
letter-spacing: .03em;
padding: .7em 2em;
border: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
height: 46px;
background: #fc2;
font-family: "Arial" inherit;
font-weight: bold;
color: inherit;
letter-spacing: 1px;
border-radius: 0 5px 5px 0;
cursor: pointer;
transition: background .3s ease-in-out;
}
/* Button Styles */
#mc-embedded-subscribe {
display: inline-block;
width: 20%;
margin: 0;
padding: 0;
}
#mc_embed_signup .mc-field-group input {
/*display: block;*/
/*width: 100%;*/
/*padding: 8px 0;*/
text-indent: 2%;
width: 200px;
}
#mc_embed_signup input.mce_inline_error {
border-color: #6B0505;
}
#mc_embed_signup input {
border: 0px solid #999;
-webkit-appearance: none;
}
#mc_embed_signup .mc-field-group label {
display: block;
margin-bottom: 3px;
}
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="//utz-benkel.us10.list-manage.com/subscribe/post?u=9684bbce9ec8413a5614ca7c3&id=116fd11541" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="NAME#EXAMPLE.COM">
<input type="submit" value="Senden" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="b_9684bbce9ec8413a5614ca7c3_116fd11541" tabindex="-1" value=""></div>
<div class="clear text-center"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->

this is because the browser refers to line items as words in the text. and between words it is necessary to put an inter-word interval.
just put a comment between the input, so that there is not a single blank or a line break between them.
#mce-EMAIL {
display: inline-block;
padding: 8px 0;
width: 70%;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 1em;
color: #343434;
padding: .7em 9em .7em 2em;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
background-color: rgb(240, 240, 240);
background-image: none;
background-repeat: repeat;
background-attachment: scroll;
background-clip: border-box;
background-origin: padding-box;
background-position-x: 0%;
background-position-y: 0%;
background-size: auto auto;
font-family: "Arial" inherit;
color: #737373;
letter-spacing: 1px;
text-indent: 5%;
border-radius: 5px 0 0 5px;
border-top-left-radius: 5px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 5px;
opacity: 0.9;
border-style:solid;
border: none;
} /* Input Styles */
.button {
clear: both;
display: inline-block;
width: 25%;
letter-spacing: .03em;
padding: .7em 2em;
border: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
height: 46px;
background: #fc2;
font-family: "Arial" inherit;
font-weight: bold;
color: inherit;
letter-spacing: 1px;
border-radius: 0 5px 5px 0;
cursor: pointer;
transition: background .3s ease-in-out;
} /* Button Styles */
#mc-embedded-subscribe{
display: inline-block;
width: 20%;
margin: 0;
padding: 0;
}
#mc_embed_signup .mc-field-group input {
/*display: block;*/
/*width: 100%;*/
/*padding: 8px 0;*/
text-indent: 2%;
width: 200px;
}
#mc_embed_signup input.mce_inline_error {
border-color: #6B0505;
}
#mc_embed_signup input {
border: 0px solid #999;
-webkit-appearance: none;
}
#mc_embed_signup .mc-field-group label {
display: block;
margin-bottom: 3px;
}
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="//utz-benkel.us10.list-manage.com/subscribe/post?u=9684bbce9ec8413a5614ca7c3&id=116fd11541" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="NAME#EXAMPLE.COM"><!--
--><input type="submit" value="Senden" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="b_9684bbce9ec8413a5614ca7c3_116fd11541" tabindex="-1" value=""></div>
<div class="clear text-center"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->

I think best solution is display: flex. No more additional css.. It remove white space and make both input height equal.
Basic concepts of flexbox
.mc-field-group {
display: flex;
}
.mc-field-group {
display: flex;
}
#mce-EMAIL {
display: inline-block;
padding: 8px 0;
width: 70%;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 1em;
color: #343434;
padding: .7em 9em .7em 2em;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
background-color: rgb(240, 240, 240);
background-image: none;
background-repeat: repeat;
background-attachment: scroll;
background-clip: border-box;
background-origin: padding-box;
background-position-x: 0%;
background-position-y: 0%;
background-size: auto auto;
font-family: "Arial" inherit;
color: #737373;
letter-spacing: 1px;
text-indent: 5%;
border-radius: 5px 0 0 5px;
border-top-left-radius: 5px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 5px;
opacity: 0.9;
border-style:solid;
border: none;
} /* Input Styles */
.button {
clear: both;
display: inline-block;
width: 25%;
letter-spacing: .03em;
padding: .7em 2em;
border: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
height: 46px;
background: #fc2;
font-family: "Arial" inherit;
font-weight: bold;
color: inherit;
letter-spacing: 1px;
border-radius: 0 5px 5px 0;
cursor: pointer;
transition: background .3s ease-in-out;
} /* Button Styles */
#mc-embedded-subscribe{
display: inline-block;
width: 20%;
margin: 0;
padding: 0;
}
#mc_embed_signup .mc-field-group input {
/*display: block;*/
/*width: 100%;*/
/*padding: 8px 0;*/
text-indent: 2%;
width: 200px;
}
#mc_embed_signup input.mce_inline_error {
border-color: #6B0505;
}
#mc_embed_signup input {
border: 0px solid #999;
-webkit-appearance: none;
}
#mc_embed_signup .mc-field-group label {
display: block;
margin-bottom: 3px;
}
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="//utz-benkel.us10.list-manage.com/subscribe/post?u=9684bbce9ec8413a5614ca7c3&id=116fd11541" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="NAME#EXAMPLE.COM">
<input type="submit" value="Senden" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="b_9684bbce9ec8413a5614ca7c3_116fd11541" tabindex="-1" value=""></div>
<div class="clear text-center"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->

The issue is the white space between your two elements. The input element are inline elements and the white space between them is displayed as a single space. There are several ways to solve it and you can even use a different design like is suggested in the other answer, but you solve it in your current design by simply removing all the white space between the two elements, like this:
#mce-EMAIL {
display: inline-block;
padding: 8px 0;
width: 70%;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 1em;
color: #343434;
padding: .7em 9em .7em 2em;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
background-color: rgb(240, 240, 240);
background-image: none;
background-repeat: repeat;
background-attachment: scroll;
background-clip: border-box;
background-origin: padding-box;
background-position-x: 0%;
background-position-y: 0%;
background-size: auto auto;
font-family: "Arial" inherit;
color: #737373;
letter-spacing: 1px;
text-indent: 5%;
border-radius: 5px 0 0 5px;
border-top-left-radius: 5px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 5px;
opacity: 0.9;
border-style: solid;
border: none;
}
/* Input Styles */
.button {
clear: both;
display: inline-block;
width: 25%;
letter-spacing: .03em;
padding: .7em 2em;
border: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0;
height: 46px;
background: #fc2;
font-family: "Arial" inherit;
font-weight: bold;
color: inherit;
letter-spacing: 1px;
border-radius: 0 5px 5px 0;
cursor: pointer;
transition: background .3s ease-in-out;
}
/* Button Styles */
#mc-embedded-subscribe {
display: inline-block;
width: 20%;
margin: 0;
padding: 0;
}
#mc_embed_signup .mc-field-group input {
/*display: block;*/
/*width: 100%;*/
/*padding: 8px 0;*/
text-indent: 2%;
width: 200px;
}
#mc_embed_signup input.mce_inline_error {
border-color: #6B0505;
}
#mc_embed_signup input {
border: 0px solid #999;
-webkit-appearance: none;
}
#mc_embed_signup .mc-field-group label {
display: block;
margin-bottom: 3px;
}
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="//utz-benkel.us10.list-manage.com/subscribe/post?u=9684bbce9ec8413a5614ca7c3&id=116fd11541" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="NAME#EXAMPLE.COM"><input type="submit" value="Senden" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="b_9684bbce9ec8413a5614ca7c3_116fd11541" tabindex="-1" value=""></div>
<div class="clear text-center"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->
Although this is a simple solution, it is not very elegant to have many elements on one long line. To split the line, you can make use of one HTML features which ignores the white space inside the tags, so just split inside the tags like this:
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="NAME#EXAMPLE.COM"
><input type="submit" value="Senden" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
Or like this:
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="NAME#EXAMPLE.COM"><
input type="submit" value="Senden" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
Or you can convert the white space to a comment like this:
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="NAME#EXAMPLE.COM"><!--
--><input type="submit" value="Senden" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
Please note that most editors may break those solutions when they reformat your HTML, so either avoid reformatting or reapply the fix afterwards.

Related

How to arrange a Three radio buttons on a same line along with label?

I am developing one page which is responsible for displaying cart items inside that i developed one more form called Customer details it contains three radio buttons , I want those three radio buttons and labels on a same line like this i need , How to place my three radio buttons and along with their label names on a same line .like this i am getting please help me to fix this issue
Cart.vue
<template>
<div class="second -section">
<div class="details-box">
<input type="text" v-if="hide==true" class="initial-btn" placeholder="Customer Details" />
</div>
<div v-if="hide==false" class="fill-details">
<form class="address" >
<h4 class="heading">Customer Details</h4>
<div class="name">
<input type="name" required pattern="[A-Za-z]{3,10}">
<label>Name</label>
</div>
<div class="name">
<input type="text" required >
<label>Phone Number</label>
</div>
<div class="pin">
<input type="text" required >
<label>PinCode</label>
</div>
<div class="pin">
<input type="text" required>
<label>Locality</label>
</div>
<div class="address-block">
<input class="address" type="text" required>
<label>Address</label>
</div>
<div class="city-landMark">
<input type="text" required >
<label>City/Town</label>
</div>
<div class="city-landMark">
<input type="text" required>
<label>LandMark</label>
</div>
<div class="Radio-Buttons">
<p>Type</p>
<div class="radio-btns">
<input type="radio" id="Home" value="Home" name="Type" v-model="role">
<label for="Home" class="home-label">Home</label>
<input type="radio" id="Work" value="Work" name="Type" v-model="role">
<label for="Work" class="work-label">Work</label>
<input type="radio" id="Other" value="Other" name="Type" v-model="role">
<label for="Other" class="other-label">Other</label>
</div>
<div class="btn-continue">
<button type="submit" class="continue" >continue</button>
</div>
</div>
</form>
</div>
</div>
</template>
<style>
#import "colors";
.container{
// background:#FFFFFF;
margin-top:25px;
margin-left:177px;
width:774px;
height:241px;
// border:1px solid #707070;
// border-radius:1px;
}
.content{
margin-left:177px;
width: 155px;
height: 22px;
text-align: left;
font: normal normal medium 18px/22px Lato;
letter-spacing: 0px;
color: $light_black;
opacity: 1;
}
.mid-section{
display:flex;
}
.mid-section img{
width: 105px;
height: 85px;
margin-top:40px;
padding-left:36px;
opacity: 1;
}
.title-section {
margin-top:40px;
padding-left:38px;
font: normal normal normal 14px/17px Lato;
letter-spacing: 0px;
color: $light_black;
opacity: 1;
width: 180px;
height: 17px;
font-weight:300;
}
.author-section {
font: normal normal normal 12px/12px Lato;
letter-spacing: 0px;
color: #9D9D9D;
opacity: 1;
width: 63px;
height: 12px;
margin-left:141px;
margin-top:-58px;
}
.price-section{
margin-left:141px;
font: normal normal bold 15px/18px Lato;
letter-spacing: 0px;
color: $light_black;
opacity: 1;
margin-top:10px;
}
.price-section h6{
font-weight:600;
}
.plus-btn{
border-radius:45%;
width: 24px;
height: 24px;
margin-left:141px;
}
.btn{
position:absolute;
width: 151px;
height: 35px;
background: #3371B5 0% 0% no-repeat padding-box;
border-radius: 2px;
opacity: 1;
margin-top:-50px;
margin-left:800px;
font: normal normal medium 14px/17px Lato;
letter-spacing: 0px;
color: $pale_white;
text-transform: uppercase;
opacity: 1;
}
.close-btn{
background:none;
border:none;
margin-top:30px;
margin-left:650px;
}
.fa-minus-circle{
font-size: larger;
background:none;
border: 1px solid $grey_white;
opacity: 1;
margin-left:141px;
}
.fa-plus-circle{
font-size: larger;
background: none;
border: 1px solid $grey_white;
opacity: 1;
}
.icons .rectangle{
width: 41px;
height: 24px;
}
.initial-btn{
width: 774px;
height: 60px;
border: 1px solid #DCDCDC;
border-radius: 1px;
font: normal normal normal 15px/18px Lato;
letter-spacing: 0px;
color: #333232;
opacity: 1;
margin-left:177px;
margin-top:5px;
}
.fill-details{
width: 774px;
height: 450px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #DCDCDC;
border-radius: 1px;
opacity: 1;
margin-left:177px;
border: 1px solid #DCDCDC;
}
.form{
position: absolute;
transform: translate(-50%, -50%);
border-radius: 10px;
width: 800px;
padding: 25px;
margin-left:177px;
}
.heading{
width: 185px;
height: 18px;
text-align: left;
font: normal normal normal 19px/18px Lato;
letter-spacing: 0px;
color: #333232;
opacity: 1;
padding-left:36px;
}
.address h4 {
font-weight: 300;
}
.name {
display: inline-block;
padding-left:36px;
}
input[type="name"] {
display: block;
margin: 30px 0 0 10px;
width: 251px;
}
.name input[type="text"]{
display: block;
margin: 30px 0 0 10px;
width: 251px;
}
.pin input[type="text"]{
display: block;
margin: 30px 0 0 10px;
width: 251px;
}
.pin{
padding-left:36px;
margin-top:-35px;
display: inline-block;
}
.city-landMark{
display: inline-block;
padding-left:36px;
margin-top:-35px;
}
.city-landMark input[type="text"]{
display: block;
margin: 30px 0 0 10px;
width: 251px;
}
.address-block input[type="text"]{
display: block;
margin: 30px 0 0 10px;
width: 550px;
height:50px;
}
.address-block{
padding-left:36px;
margin-top:-35px;
display: inline-block;
}
.Radio-Buttons p{
padding-left: 50px;
}
#home-label{
padding-top:50px;
}
.btn-continue{
padding-left:550px;
}
.continue{
width: 160px;
height: 35px;
background: #3371B5 0% 0% no-repeat padding-box;
border-radius: 3px;
opacity: 1;
font: normal normal medium 14px/17px Lato;
letter-spacing: 0px;
color: #FFFFFF;
text-transform: uppercase;
opacity: 1;
}
.home-label{
padding-left: 25px;
}
form input {
outline: none;
border: 1px solid #9c9c9c;
border-radius: 5px;
padding: 0 10px;
height: 35px;
font-size: 15px;
margin-left:177px;
}
input:focus {
border: 1.5px solid #1f52f9;
}
form label {
position: relative;
font-family: roboto;
color: #555;
font-size: 15px;
pointer-events: none;
left: 20px;
top: -28px;
transition: .2s all;
}
input:focus~label,
input:valid~label {
top: -49px;
left: 15px;
background: #fff;
padding: 0 5px;
font-size: 10px;
color: #1f52f9;
}
</style>
You have directly use the element selector by tag name instead by class or ID. So, other label element are also affected by that styling.
Please review your CSS code and give property to specific element by using class or ID or other selector instead of directly selecting by tag name.
I wrapped each radio buttons in a div and made those div a flexbox and gave them a gap to space out.
.radio-btns{
display: flex;
gap: 3rem;
}
<div class="radio-btns">
<div>
<input type="radio" id="Home" value="Home" name="Type" v-model="role">
<label for="Home">Home</label>
</div>
<div>
<input type="radio" id="Work" value="Work" name="Type" v-model="role">
<label for="Work" class="work-label">Work</label>
</div>
<div>
<input type="radio" id="Other" value="Other" name="Type" v-model="role">
<label for="Other">Other</label>
</div>
</div>

Input:focus not working

At first my input focus was working just fine, now all of a sudden when I add a couple of more styles to my input, it suddenly stops working. I've only added the 'input[type="text"] and border-radius and padding and some margins since when it was working. When you click each form element, nothing happens even though I have a rule for focus(which you can find near the bottom of the code). Is there any workaround for this?
form{
position: absolute;
left: 50%;
color: white;
margin-left: -180px;
padding: 15px 30px 15px 30px;
background-color: #26004d;
border-radius: 7px;
margin-top: 10px;
width: 300px;
}
label{
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
}
input:focus {
border: 2px solid #862d59;
}
input[type="submit"]{
width: 50%;
background-color: #862d59;
color: white;
margin-top: 5px;
padding: 12px 12px;
border: none;
cursor: pointer;
}
input[type="text"]{
width: 100%;
padding: 12px 12px;
margin: 4px 0;
border: 1px solid #ccc;
border-radius: 6px;
//box-sizing: border-box;
}
<div id="formholder1">
<form>
<div class="single-field">
<label for="Username">Username:</label>
<input name="Name" type="text"></input>
</div>
<div class="single-field">
<label for="Password">Password:</label>
<input name="Password" type="text"></input>
</div>
<input type="submit" value="Login">
</form>
</div>
Use this input[type="text"]:focus {
border: 2px solid #862d59;
}
learn it - http://www.w3schools.com/cssref/trysel.asp?selector=:focus
example - https://css-tricks.com/snippets/css/glowing-blue-input-highlights/
now its working
form{
position: absolute;
left: 50%;
color: white;
margin-left: -180px;
padding: 15px 30px 15px 30px;
background-color: #26004d;
border-radius: 7px;
margin-top: 10px;
width: 300px;
}
label{
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
}
input[type="text"]:focus {
border: 2px solid #862d59;
}
input:focus {
border: 2px solid red;
}
input[type="submit"]{
width: 50%;
background-color: #862d59;
color: white;
margin-top: 5px;
padding: 12px 12px;
border: none;
margin-left:-10px;
cursor: pointer;
}
input[type="text"]{
width: 100%;
padding: 12px 12px;
margin: 4px 0;
border: 1px solid #ccc;
border-radius: 6px;
margin-left:-15px;
//box-sizing: border-box;
}
<div id="formholder1">
<form>
<div class="single-field">
<label for="Username">Username:</label>
<input name="Name" type="text"></input>
</div>
<div class="single-field">
<label for="Password">Password:</label>
<input name="Password" type="text"></input>
</div>
<input type="submit" value="Login">
</form>
</div>
Put Your :focus property after input.
input[type="text"]:focus {
border: 5px solid #862d59;
}
form{
position: absolute;
left: 50%;
color: white;
margin-left: -180px;
padding: 15px 30px 15px 30px;
background-color: #26004d;
border-radius: 7px;
margin-top: 10px;
width: 300px;
}
label{
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
}
input[type="submit"]{
width: 50%;
background-color: #862d59;
color: white;
margin-top: 5px;
padding: 12px 12px;
border: none;
cursor: pointer;
}
input[type="text"]{
width: 100%;
padding: 12px 12px;
margin: 4px 0;
border: 1px solid #ccc;
border-radius: 6px;
box-sizing: border-box;
}
input[type="text"]:focus {
border: 5px solid #862d59;
}
<div id="formholder1">
<form>
<div class="single-field">
<label for="Username">Username:</label>
<input name="Name" type="text"></input>
</div>
<div class="single-field">
<label for="Password">Password:</label>
<input name="Password" type="text"></input>
</div>
<input type="submit" value="Login">
</form>
</div>

Have the submit button uncentered

I'm trying to create a login "panel" kindof.
I just want the submit button right next to the password field but without it centering with the password field.
I have tried to uncenter the Submit button but it doesn't work.
.login input:focus {
border-color: #419ebf;
outline-width: 0;
}
.login {
cursor: default;
margin-top: 100px;
text-align: center;
}
.login .fields {
background-color: rgba(0, 0, 0, 0.18);
border-color: #b8bfb7;
width: 325px;
height: 50px;
font-family:'Exo', sans-serif;
font-size: 30px;
color: White;
border-radius: 7px;
padding-left: 4px;
padding-right: 4px;
margin: 5px auto;
}
.login .submit {
width: 150px;
height: 50px;
background-color: rgba(0, 0, 0, 0.18);
border-color: #b8bfb7;
font-family:'Exo', sans-serif;
font-size: 30px;
color: White;
border-radius: 7px;
}
<form method="post" action="login.php" class="login">
<input class="fields" type="text" name="username" placeholder="Username" />
<br/>
<input class="fields" type="password" name="password" placeholder="Password" />
<input class="submit" type="submit" value="Login">
</form>
Thanks for the help
You could consider two things:
If your application is always displayed on fixed width, you might like to try use position: fixed; instead of centering all items and using newline.
If you'd like to be more flexible, find an anchestor or container element and use position: absolute;.
More information on positioning elements through CSS can be found here.
Try to delete
text-align: center;
in
.login{
cursor: default;
margin-top: 100px;
text-align: center;
}
I have removed text-align: center; from .login, added width: 500px; and changed margins to margin: 100px auto 0 auto;
.login {
cursor: default;
margin: 100px auto 0 auto;
width: 500px;
}
.login input:focus {
border-color: #419ebf;
outline-width: 0;
}
.login .fields {
background-color: rgba(0, 0, 0, 0.18);
border-color: #b8bfb7;
width: 325px;
height: 50px;
font-family:'Exo', sans-serif;
font-size: 30px;
color: White;
border-radius: 7px;
padding-left: 4px;
padding-right: 4px;
margin: 5px auto;
}
.login .submit {
width: 150px;
height: 50px;
background-color: rgba(0, 0, 0, 0.18);
border-color: #b8bfb7;
font-family:'Exo', sans-serif;
font-size: 30px;
color: White;
border-radius: 7px;
}
<form method="post" action="login.php" class="login">
<input class="fields" type="text" name="username" placeholder="Username" />
<br/>
<input class="fields" type="password" name="password" placeholder="Password" />
<input class="submit" type="submit" value="Login">
</form>

HTML form submit button is not vertically centered

This is my first time posting, so I hope I'm doing this right.
I want to style a search bar like this one
The problem is, the submit button is always a little off vertically in comparison to the text-input. No matter what I do, there is always at least 1px offset. Help is MUCH appreciated!
I have the following code:
.searchfield{
-webkit-appearance:none;
border: 3px solid #1a5087;
border-right: 0px;
border-radius: 3px;
height: 30px;
font-size: 20px;
margin: 0px;
margin-top: 0px;
outline: 0;
display: inline;
}
.searchbutton{
-webkit-appearance:none;
background-color: #ffb800;
height: 36px;
border: 3px solid #ffb800;
width: 40px;
color: white;
margin-left: -25px;
cursor: pointer;
outline: 0;
background-repeat:no-repeat;
background-position: 2px 2px;
margin-top: 5px;
display: inline;
}
<form action="action.php" method="post">
<input type="number" name="name" placeholder="placeholder" required class="searchfield">
<input type="submit" value="search" class="searchbutton">
</form>
I have tried to rebuilt the same in fiddle. Have a look here
<form class="form-wrapper cf">
<input type="text" placeholder="Search here..." required>
<button type="submit">Search</button>
</form>
A couple of CSS changes should fix the alignment:
Add vertical-align: middle; to both .searchfield and .searchbutton to align them to the middle of each other
Add padding: 0; to .searchfield to remove any padding that the browser may apply to it by default
Remove margin-top: 5px; from .searchbutton to stop it from being pushed down
.searchfield{
-webkit-appearance:none;
border: 3px solid #1a5087;
border-right: 0px;
border-radius: 3px;
height: 30px;
font-size: 20px;
margin: 0px;
margin-top: 0px;
outline: 0;
display: inline;
padding: 0;
vertical-align: middle;
}
.searchbutton{
-webkit-appearance:none;
background-color: #ffb800;
height: 36px;
border: 3px solid #ffb800;
width: 40px;
color: white;
margin-left: -25px;
cursor: pointer;
outline: 0;
background-repeat:no-repeat;
background-position: 2px 2px;
/*margin-top: 5px;*/
display: inline;
vertical-align: middle;
}
<form action="action.php" method="post">
<input type="number" name="name" placeholder="placeholder" required class="searchfield">
<input type="submit" value="search" class="searchbutton">
</form>

How to delete empty space between form elements

How I can delete empty space between search input box and the go button? I've prepared jsfiddle with code sample. Link - jsFiddle
Screenshot:
HTML:
<div class="blablabla">
<form id="search_mini" action="#" method="get">
<div class="form-search">
<!--<label for="search"></label>-->
<input id="search" value="SEARCH" type="text" name="q" class="input-text" maxlength="128" autocomplete="off">
<button type="submit" title="GO" class="button"><span><span>GO</span></span>
</button>
<div id="search_autocomplete" class="search-autocomplete" style="display: none;"></div>
</div>
</form>
CSS:
#search_mini {
width: 268px;
}
.form-search input {
border-color: #7d7c7c;
height: 30px;
width: 150px;
padding:0;
}
.form-search button.button {
background: url(../images/bg.gif) 0 0 repeat-x;
font-size: 12px;
text-align: center;
padding: 0;
height: 36px;
min-width: 84px;
}
Thank you in advance.
You may try margin-left:
#search_mini {
width: 268px;
}
.form-search input {
border-color: #7d7c7c;
height: 30px;
width: 150px;
padding: 0;
}
.form-search button.button {
background: url(../images/bg.gif) 0 0 repeat-x;
font-size: 12px;
text-align: center;
padding: 0;
height: 36px;
min-width: 84px;
margin-left: -4px;/* put as your need */
}
<div class="blablabla">
<form id="search_mini" action="#" method="get">
<div class="form-search">
<!--<label for="search"></label>-->
<input id="search" value="SEARCH" type="text" name="q" class="input-text" maxlength="128" autocomplete="off">
<button type="submit" title="GO" class="button"><span><span>GO</span></span>
</button>
<div id="search_autocomplete" class="search-autocomplete" style="display: none;"></div>
</div>
</form>
add float:left to you .form-search input element
example: http://jsfiddle.net/2nwp36nj/2/
#search_mini {
width: 268px;
}
.form-search input {
border-color: #7d7c7c;
height: 30px;
width: 150px;
padding:0;
float: left;
}
.form-search button.button {
background: url(../images/bg.gif) 0 0 repeat-x;
font-size: 12px;
text-align: center;
padding: 0;
height: 36px;
min-width: 84px;
}
<div class="blablabla">
<form id="search_mini" action="#" method="get" _lpchecked="1">
<div class="form-search">
<!--<label for="search"></label>-->
<input id="search" value="SEARCH" type="text" name="q" class="input-text" maxlength="128" autocomplete="off">
<button type="submit" title="GO" class="button"><span><span>GO</span></span>
</button>
<div id="search_autocomplete" class="search-autocomplete" style="display: none;"></div>
</div>
</form>
</div>
use float left for both of the elements input and button also you need to give a width for button as well. It looks like it is working in the below code.
http://jsfiddle.net/2nwp36nj/3/
#search_mini {
width: 368px;
}
.form-search input, .form-search button {
border-color: #7d7c7c;
height: 30px;
width: 150px;
padding:0;
float: left;
}
.form-search button.button {
background: url(../images/bg.gif) 0 0 repeat-x;
font-size: 12px;
text-align: center;
padding: 0;
height: 36px;
min-width: 84px;
}
are suggested just such a button then she together with the form DEMO
<form class="form-wrapper cf">
<input type="text" placeholder="search" required>
<button type="submit">GO</button>
</form>
.cf:before, .cf:after{
content:"";
display:table;
}
.cf:after{
clear:both;
}
.cf{
zoom:1;
}
.form-wrapper {
width: 450px;
padding: 15px;
margin: 150px auto 50px auto;
background: #444;
background: rgba(0,0,0,.2);
border-radius: 10px;
box-shadow: 0 1px 1px rgba(0,0,0,.4) inset, 0 1px 0 rgba(255,255,255,.2);
}
.form-wrapper input {
width: 330px;
height: 20px;
padding: 10px 5px;
float: left;
font: bold 15px 'lucida sans', 'trebuchet MS', 'Tahoma';
border: 0;
background: #eee;
border-radius: 3px 0 0 3px;
}
.form-wrapper input:focus {
outline: 0;
background: #fff;
box-shadow: 0 0 2px rgba(0,0,0,.8) inset;
}
.form-wrapper input::-webkit-input-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
.form-wrapper input:-moz-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
.form-wrapper input:-ms-input-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
.form-wrapper button {
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 40px;
width: 110px;
font: bold 15px/40px 'lucida sans', 'trebuchet MS', 'Tahoma';
color: #fff;
text-transform: uppercase;
background: #d83c3c;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
}
.form-wrapper button:hover{
background: #e54040;
}
.form-wrapper button:active,
.form-wrapper button:focus{
background: #c42f2f;
outline: 0;
}
.form-wrapper button:before {
content: '';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent #d83c3c transparent;
top: 12px;
left: -6px;
}
.form-wrapper button:hover:before{
border-right-color: #e54040;
}
.form-wrapper button:focus:before,
.form-wrapper button:active:before{
border-right-color: #c42f2f;
}
.form-wrapper button::-moz-focus-inner {
border: 0;
padding: 0;
}
Simply add this to your elements :
.form-search input,
.form-search button.button
{
display: block;
float: left;
}
Your space is actually due to a whitespace.
Another working solution: you must insert comment between input tag and button tag. Like this:
<input id="search" value="SEARCH" type="text" name="q" class="input-text" maxlength="128" autocomplete="off"><!--
--><button type="submit" title="GO" class="button"><span><span>GO</span></span>