Id like to have a text input with a submit button inside the input and have the edges rounded using something like border-radius
Im using the css from the second answer in this question:
How to add button inside input
#form {
display:flex;
flex-direction:row;
border:1px solid grey;
padding:2px;
border-radius:50px; /* this is me trying to round edges of input*/
}
#input {
flex-grow:2;
border:none;
}
but when I add that border-radius the button no longer appears inside the input
how could I do it?
There are a couple of errors in your code. First, form and input are native tags, they don't need a hashtag in the css. If you assign an id to the form, that wil be your #id (i've given the form an id of 'form' for demo purposes.
You can give the form a border radius, but to make the buttons rounded without rounding the entire form, you need to add a border-radius to the input. You can assign a border-radius to all inputs by using input (general) or specify the type input[type=submit] in your css
Hope this helps
#form {
width: 60%;
display: flex;
flex-direction: row;
border: 1px solid grey;
padding: 2px;
border-radius: 50px; /*you can remove this to avoid rounded corners on the form*/
}
input {
flex-grow: 2;
border: none;
border-radius: 50px;
}
<form id="form">
<input type="text" placeholder="text" />
<input type="submit" value="Click here" />
</form>
How about something like this? The <form> is now just a flex container, and the border styles are actually applied to the input and the button.
#my-form {
display: flex;
flex-direction: row;
}
#my-form input,
#my-form button {
border-radius: 10px;
border: 1px solid grey;
padding: 2px;
}
#my-form input {
flex-grow: 2;
border-right-width: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
#my-form button {
background: teal;
color: white;
border-left-width: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
<form id="my-form">
<input type="text" />
<button type="submit">my button</button>
</form>
:root {
--border-width: 4px;
--border-radius: 10px;
--height: 40px;
}
input[type="text"],
input[type="submit"] {
transition: box-shadow .3s;
}
input[type="text"] {
width: 200px;
height: var(--height);
padding: 3px 60px 3px 5px;
border-radius: calc(var(--border-width, 1px) + var(--border-radius, 10px));
border-width: var(--border-width, 1px);
box-sizing: border-box;
border-color: blue;
border-style: solid;
}
input[type="text"]:hover,
input[type="text"]:focus {
outline: none;
box-shadow: 0px 0px 2px 3px blue;
}
input[type="submit"] {
transform: translateX(calc(-100% - var(--border-width, 1px)));
height: calc(var(--height) - 2 * var(--border-width));
background: blue;
color: white;
border: 0;
-webkit-appearance: none;
border-radius: 0 var(--border-radius, 10px) var(--border-radius, 10px) 0;
}
input[type="submit"]:hover,
input[type="submit"]:focus {
outline: none;
box-shadow: inset 0px 0px 2px 3px white;
}
<input type="text"><input type="submit">
You have to add a border and the border-radius to the input text element.
In the example you linked, it would be like this:
input[type="text"] {
width: 200px;
height: 20px;
padding-right: 50px;
border: 2px solid black;
border-radius: 30px;
}
EDIT:
If the border is supposed to go around both elements, then you could add this CSS to the button:
border: 3px solid black;
border-left: 0;
border-radius: 0 30px 30px 0;
Like here: http://jsfiddle.net/jeft24m6/
Related
I can't change border color when the input field is active. I tried using input:active, input:focus. What I want is the color of input's border to change when user clicks on it.
The CSS code :
input {
margin-top: 20px;
border-radius: 0px;
background-color: #FFFFFF;
border: 1px solid black;
height: 33px;
width: 200px;
&:active {
font-size: 13px;
border: 2px solid Red;
background-color: #ffffff;
}
&:disabled {
border: 1px #Black;
border-radius: 0px;
background-color: #F9FAFB;
}
HTML Code:
<div class="container">
<form>
<label for="input-field">Text</label>
<input type="text" placeholder="...">
<button>..</button>
</form>
</div>
So this is a few things, your css isn't valid, you've written scss syntax. If you're aware of this and the question is meant to say "scss", then you need to add outline: none;. Also #black isn't a valid colour.
Example in scss:
input {
margin-top: 20px;
border-radius: 0px;
background-color: #FFFFFF;
border: 1px solid black;
height: 33px;
width: 200px;
&:active, &:focus { // I think you said you wanted focus as well
font-size: 13px;
border: 2px solid red;
outline: none; // add this
background-color: #ffffff;
}
&:disabled {
border: 1px solid black; // update this
border-radius: 0px;
background-color: #F9FAFB;
}
}
In css:
input:active, input:focus { // I think you said you wanted focus as well
font-size: 13px;
border: 2px solid red;
outline: none; // add this
background-color: #ffffff;
}
You can't use the & in regular css.
#Black isn't a css colour value.
You need outline: none to override the browser's default focus behaviour.
I want to grow the element background and font on hover. However it does impact all other elements position like the border of the form, elements side.
I tried to do it with the box-shadow but only the shadow is enlarged and not the text.
please Help
LINk: Code for HTML and CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
text-align: center;
}
.contenedor {
display: inline-block;
width: 400px;
height: 400px;
}
form {
padding: 30px;
border: 1px solid #ccc;
}
input[type="submit"] {
width: 80px;
background: #24b080;
padding: 10px;
border: 1px solid #24b080;
cursor: pointer;
color: white;
margin-top: 10px;
margin-bottom: 10px;
transition: all 0.3s ease-out;
}
input[type="submit"]:hover {
background-color: #24b080;
border: 2px solid #24b080;
color: #fff;
transform: scale(1.2, 1.2);
}
<form name="formulario" action="">
<input type="submit" value="Send">
<input type="submit" value="OK">
<input type="submit" value="Cancel">
</form>
You can change this
form {
padding: 30px;
border: 1px solid #ccc;
}
to this:
form {
padding: 30px;
border: 1px solid #ccc;
height: 120px;
}
If you give the Form a fixed height then it cannot move when the buttons get bigger.
You can apply vertical-align: top; to input[type="submit"] to avoid the slight vertical movement on hover (I guess that's what you meant?):
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
text-align: center;
}
.contenedor {
display: inline-block;
width: 400px;
height: 400px;
}
form {
padding: 30px;
border: 1px solid #ccc;
}
input[type="submit"] {
width: 80px;
background: #24b080;
padding: 10px;
border: 1px solid #24b080;
cursor: pointer;
color: white;
margin-top: 10px;
margin-bottom: 10px;
transition: all 0.3s ease-out;
vertical-align: top;
}
input[type="submit"]:hover {
background-color: #24b080;
border: 2px solid #24b080;
color: #fff;
transform: scale(1.2, 1.2);
}
<form name="formulario" action="">
<input type="submit" value="Send">
<input type="submit" value="OK">
<input type="submit" value="Cancel">
</form>
I've only been doing HTML and CSS for a total of one month. I'm currently trying to replicate a Google search bar, but the problem is that I can't seem to fit the search icon and the voice icon inside the search bar. I've read that you're supposed to put the search bar's position as relative and the icons' as absolute, but I've apparently screwed up the code somewhere and can't figure it out. Thank you <3
My code (HTML and CSS):
input {
color: rgba(0,0,0,.87);
width: 600px;
padding: 15px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
z-index: -1;
}
input:focus {
outline: none;
}
input:hover {
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
.voice {
height:20px;
top: 5px;
left: 10px;
position: absolute;
margin-right: 30px;
}
.search-icon {
color: rgb(154, 160, 166);
position: absolute;
z-index: 0;
}
.wrapper {
position: relative;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDU2Ljk2NiA1Ni45NjYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDU2Ljk2NiA1Ni45NjY7IiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4Ij4KPHBhdGggZD0iTTU1LjE0Niw1MS44ODdMNDEuNTg4LDM3Ljc4NmMzLjQ4Ni00LjE0NCw1LjM5Ni05LjM1OCw1LjM5Ni0xNC43ODZjMC0xMi42ODItMTAuMzE4LTIzLTIzLTIzcy0yMywxMC4zMTgtMjMsMjMgIHMxMC4zMTgsMjMsMjMsMjNjNC43NjEsMCw5LjI5OC0xLjQzNiwxMy4xNzctNC4xNjJsMTMuNjYxLDE0LjIwOGMwLjU3MSwwLjU5MywxLjMzOSwwLjkyLDIuMTYyLDAuOTIgIGMwLjc3OSwwLDEuNTE4LTAuMjk3LDIuMDc5LTAuODM3QzU2LjI1NSw1NC45ODIsNTYuMjkzLDUzLjA4LDU1LjE0Niw1MS44ODd6IE0yMy45ODQsNmM5LjM3NCwwLDE3LDcuNjI2LDE3LDE3cy03LjYyNiwxNy0xNywxNyAgcy0xNy03LjYyNi0xNy0xN1MxNC42MSw2LDIzLjk4NCw2eiIgZmlsbD0iIzAwMDAwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>
So what you need to do is that it's not the text field that has the rounded corners and shadows, with the icons on top, but it's the wrapper that needs to have the rounded corners and borders and every, then the three elements all go inside of it.
so what I did is that I took your styles for the input, and moved it too the wrapper, then make the border:none, so the input is basically invisible.
then I removed all of your position styles because they aren't needed, so now we are basically done, except the elements are slightly off center, and the input doesn't fill the whole width.
I just decided to use display:flex on the wrapper, with flex-direction:row to make all of it horizontal, with align-items: center to center everything. I also added flex-grow:1 to the input so it fills the entire width.
input {
color: rgba(0,0,0,.87);
outline-color: none;
background-color: transparent;
border:none;
height:100%;
flex-grow:1;
font-size: 15px;
}
input:focus {
outline: none;
}
.voice {
height:20px;
margin: 0px 5px;
}
.search-icon {
color: rgb(154, 160, 166);
margin: 0px 5px;
}
.wrapper {
width: 600px;
height: 30px;
padding: 2px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
display:flex;
flex-direction: row;
align-items: center;
}
.wrapper:hover{
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDU2Ljk2NiA1Ni45NjYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDU2Ljk2NiA1Ni45NjY7IiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4Ij4KPHBhdGggZD0iTTU1LjE0Niw1MS44ODdMNDEuNTg4LDM3Ljc4NmMzLjQ4Ni00LjE0NCw1LjM5Ni05LjM1OCw1LjM5Ni0xNC43ODZjMC0xMi42ODItMTAuMzE4LTIzLTIzLTIzcy0yMywxMC4zMTgtMjMsMjMgIHMxMC4zMTgsMjMsMjMsMjNjNC43NjEsMCw5LjI5OC0xLjQzNiwxMy4xNzctNC4xNjJsMTMuNjYxLDE0LjIwOGMwLjU3MSwwLjU5MywxLjMzOSwwLjkyLDIuMTYyLDAuOTIgIGMwLjc3OSwwLDEuNTE4LTAuMjk3LDIuMDc5LTAuODM3QzU2LjI1NSw1NC45ODIsNTYuMjkzLDUzLjA4LDU1LjE0Niw1MS44ODd6IE0yMy45ODQsNmM5LjM3NCwwLDE3LDcuNjI2LDE3LDE3cy03LjYyNiwxNy0xNywxNyAgcy0xNy03LjYyNi0xNy0xN1MxNC42MSw2LDIzLjk4NCw2eiIgZmlsbD0iIzAwMDAwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>
I also changed some padding and stuff slightly to make it work better but I guess that's optional
input {
font-size:20px;
width: 88%;
border:none;
margin-left:60px;
height:30px;
padding:0;
}
input:focus {
outline: none;
}
.wrapper:hover {
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
.voice {
height:20px;
top: 10px;
left: 40px;
position: absolute;
margin-right: 30px;
}
.search-icon {
color: rgb(154, 160, 166);
position: absolute;
z-index: 0;
left: 15px;
top: 10px;
cursor:default;
}
.wrapper {
position: relative;
color: rgba(0,0,0,.87);
width: 600px;
padding:5px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDU2Ljk2NiA1Ni45NjYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDU2Ljk2NiA1Ni45NjY7IiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4Ij4KPHBhdGggZD0iTTU1LjE0Niw1MS44ODdMNDEuNTg4LDM3Ljc4NmMzLjQ4Ni00LjE0NCw1LjM5Ni05LjM1OCw1LjM5Ni0xNC43ODZjMC0xMi42ODItMTAuMzE4LTIzLTIzLTIzcy0yMywxMC4zMTgtMjMsMjMgIHMxMC4zMTgsMjMsMjMsMjNjNC43NjEsMCw5LjI5OC0xLjQzNiwxMy4xNzctNC4xNjJsMTMuNjYxLDE0LjIwOGMwLjU3MSwwLjU5MywxLjMzOSwwLjkyLDIuMTYyLDAuOTIgIGMwLjc3OSwwLDEuNTE4LTAuMjk3LDIuMDc5LTAuODM3QzU2LjI1NSw1NC45ODIsNTYuMjkzLDUzLjA4LDU1LjE0Niw1MS44ODd6IE0yMy45ODQsNmM5LjM3NCwwLDE3LDcuNjI2LDE3LDE3cy03LjYyNiwxNy0xNywxNyAgcy0xNy03LjYyNi0xNy0xN1MxNC42MSw2LDIzLjk4NCw2eiIgZmlsbD0iIzAwMDAwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>
input {
color: rgba(0,0,0,.87);
width: 600px;
padding: 15px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
}
input:focus {
outline: none;
}
input:hover {
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
.voice {
height:20px;
top: 10;
right: 40;
position: absolute;
margin-right: 30px;
}
.search-icon {
color: rgb(154, 160, 166);
position: absolute;
right:20;
top:10;
}
.wrapper {
width:600px;
position: relative;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDU2Ljk2NiA1Ni45NjYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDU2Ljk2NiA1Ni45NjY7IiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4Ij4KPHBhdGggZD0iTTU1LjE0Niw1MS44ODdMNDEuNTg4LDM3Ljc4NmMzLjQ4Ni00LjE0NCw1LjM5Ni05LjM1OCw1LjM5Ni0xNC43ODZjMC0xMi42ODItMTAuMzE4LTIzLTIzLTIzcy0yMywxMC4zMTgtMjMsMjMgIHMxMC4zMTgsMjMsMjMsMjNjNC43NjEsMCw5LjI5OC0xLjQzNiwxMy4xNzctNC4xNjJsMTMuNjYxLDE0LjIwOGMwLjU3MSwwLjU5MywxLjMzOSwwLjkyLDIuMTYyLDAuOTIgIGMwLjc3OSwwLDEuNTE4LTAuMjk3LDIuMDc5LTAuODM3QzU2LjI1NSw1NC45ODIsNTYuMjkzLDUzLjA4LDU1LjE0Niw1MS44ODd6IE0yMy45ODQsNmM5LjM3NCwwLDE3LDcuNjI2LDE3LDE3cy03LjYyNiwxNy0xNywxNyAgcy0xNy03LjYyNi0xNy0xN1MxNC42MSw2LDIzLjk4NCw2eiIgZmlsbD0iIzAwMDAwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>
This question already has answers here:
spacing between form fields
(4 answers)
Closed 3 years ago.
I'm working on an autocomplete form, but I seem to have some issues with the padding between the text and submit form. I cannot seem to adjust the spacing between the text and submit items, which I need because when I increase the size of the text field, it overwrites the submit button. I believe I've tried all types of padding but they do nothing. Can someone give me a clue please?
.autocomplete {
position: relative;
display: inline-block;
}
input {
border: 1px solid;
padding: 5px;
font-size: 24px;
}
input[type=text] {
border-color: #808080;
background-color: #fff;
width: 100%;
-webkit-border-radius: 5px;
padding: 5px;
}
input[type=submit] {
margin-left: 5px;
padding: 5px;
background: #ccc;
cursor: pointer;
-webkit-border-radius: 5px;
border: 1px solid;
background-color: DodgerBlue;
border-color: #CCCCCC;
color: #fff;
}
<form autocomplete="off" action="/action_page.php">
<div class="autocomplete" style="width:300px;">
<input id="myInput" type="text" name="myCountry" placeholder="Country">
</div>
<input type="submit">
</form>
Add box-sizing: border-box to your input[type=text] - the default content-box setting means that when you add padding to an element it increases its dimensions.
See demo below:
.autocomplete {
position: relative;
display: inline-block;
}
input {
border: 1px solid;
padding: 5px;
font-size: 24px;
}
input[type=text] {
border-color: #808080;
background-color: #fff;
width: 100%;
-webkit-border-radius: 5px;
padding: 5px;
box-sizing: border-box; /* added */
}
input[type=submit] {
margin-left: 5px;
padding: 5px;
background: #ccc;
cursor: pointer;
-webkit-border-radius: 5px;
border: 1px solid;
background-color: DodgerBlue;
border-color: #CCCCCC;
color: #fff;
}
<form autocomplete="off" action="/action_page.php">
<div class="autocomplete" style="width:300px;">
<input id="myInput" type="text" name="myCountry" placeholder="Country">
</div>
<input type="submit">
</form>
You can see more examples here:
Add border to div increase div width?
border-box isn't working as expected
Have you tried using between your input text and submit button?
.autocomplete {
position: relative;
display: inline-block;
}
input {
border: 1px solid;
padding: 5px;
font-size: 24px;
}
input[type=text] {
border-color: #808080;
background-color: #fff;
width: 100%;
-webkit-border-radius: 5px;
padding: 5px;
}
input[type=submit] {
margin-left: 5px;
padding: 5px;
background: #ccc;
cursor: pointer;
-webkit-border-radius: 5px;
border: 1px solid;
background-color: DodgerBlue;
border-color: #CCCCCC;
color: #fff;
}
<form autocomplete="off" action="/action_page.php">
<div class="autocomplete" style="width:300px;">
<input id="myInput" type="text" name="myCountry" placeholder="Country">
</div>
<input type="submit">
</form>
You can increase the value of margin-left in input[type=submit] {} like shown below:
input[type=submit] {
margin-left: 10px; /* increased value */
padding: 5px;
background: #ccc;
cursor: pointer;
-webkit-border-radius: 5px;
border: 1px solid;
background-color: DodgerBlue;
border-color: #CCCCCC;
color: #fff;
}
or add margin right to the previous element like shown below:
input[type=text] {
border-color: #808080;
background-color: #fff;
width: 100%;
-webkit-border-radius: 5px;
padding: 5px;
margin-right: 5px; /* add margin right */
}
Is it possible to style the center circle of a selected radio button, at least in webkit browsers…?
What I have now:
What I want:
I can change the background color, shadow etc as follows
#searchPopup input[type="radio"]{
-webkit-appearance:none;
box-shadow: inset 1px 1px 1px #000000;
background:#fff;
}
#searchPopup input[type="radio"]:checked{
-webkit-appearance:radio;
box-shadow: none;
background:rgb(252,252,252);
}
Any ideas..?
You can mimic the radio button using some round border trick (to render the outer circle) and the pseudo-element :before (to render the inner circle) which can fortunately be used on an input field of radio type:
input[type='radio'] {
-webkit-appearance:none;
width:20px;
height:20px;
border:1px solid darkgray;
border-radius:50%;
outline:none;
box-shadow:0 0 5px 0px gray inset;
}
input[type='radio']:hover {
box-shadow:0 0 5px 0px orange inset;
}
input[type='radio']:before {
content:'';
display:block;
width:60%;
height:60%;
margin: 20% auto;
border-radius:50%;
}
input[type='radio']:checked:before {
background:green;
}
Working Demo.
You can bind radio-button to label, than you can hide radio-button and style label whatever you like. Example.
div {
background-color: #444444;
display: flex-column;
display:webkit-flex-column;
}
input {
margin: 10px;
position: absolute;
left: 100px;
}
label {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
margin: 10px;
display: block;
width: 30px;
height: 30px;
border-radius: 50%;
-webkit-border-radius: 50%;
background-color: #ffffff;
box-shadow: inset 1px 0 #000000;
}
#green {
border: 8px solid green;
}
#red {
border: 8px solid red;
}
input:checked + #green {
border: 8px solid #ffffff;
background-color:green !important;
}
input:checked + #red {
border: 8px solid #ffffff;
background-color: red !important;
}
Click a button on the left - radio button on the right will be checked.
<div>
<input id="greenInput" type="radio" name="someName">
<label id="green" for="greenInput"> </label>
<input id="redInput" type="radio" name="someName">
<label id="red" for="redInput"></label>
</div>
You could also apply a background-image when the radio button is checked
[type="radio"]:checked {
width: 16px;
height: 16px;
-webkit-appearance: none;
background-image: ...
}
An example: http://jsfiddle.net/yZ6tM/