I am trying to create a search input box that expands to the left when it is centered, just like the Google mobile website. I am trying to do this using only css .
Search field if it is not concentrated in Safari (mac / iOS). the white space on the left is the company logo. Note that there is no space between the input text box and the search button. The input field has position:absolute, left:120px, right:80px.

The search field is focused. I change the input field lefton 0to input:focus.

Search box if it is not focused on Firefox. Conflicting absolute position values left:120px, right:80pxlead to a space between the text input box and the button in Chrome / Firefox.

What can I create for this input field with open extension only with css and without specifying a constant value for width.
Here is a working example on Codepen .
Here is the code ...
header {
padding: 0;
}
input[type='text'] {
left: 120px;
position: absolute;
right: 77px;
top: 0;
transition-duration: 100ms;
}
input[type='text']:focus {
left: 0;
transition-duration: 300ms;
}
input[type='submit'] {
background: #1352ec;
color: #fff;
position: absolute;
right: 0;
top: 0;
width: 80px;
}
<header>
<form method="get" action="/search">
<input class="clearable" type="text" value="ipad"/>
<input type="submit" value="Search"/>
</form>
</header>
Run codeHide result
source
share