I have these text field and button for search and some other button:
button {
font-family: Arial Narrow, sans-serif;
font-size: 20pt;
}
.search {}
.search:after {
content: "";
clear: both;
display: table
}
.search input {
font-family: Arial Narrow, sans-serif;
font-size: 20pt;
width: 160px;
height: 42px;
padding-left: 15px;
border-radius: 42px;
border: 2px solid #404040;
background: #FFDFBF;
outline: none;
position: relative;
transition: .3s linear;
}
.search input:focus {
width: 512px;
}
.search button {
width: 42px;
height: 42px;
background: none;
border: none;
position: relative;
left: -44px;
}
<DIV class="search">
<INPUT type=text name="q">
<BUTTON>🔎</BUTTON>
</DIV>
<BUTTON>Some other button...</BUTTON>
<BUTTON>Some other button 2...</BUTTON>
I need other buttons to be placed right of the text field when it is in the normal state but NOT to move when the text field is resized (they must be behind the field).
But the search button must remain bound to the right side of the text field.
Who knows how to do this?
2
Answers
You need to wrap the content in div
position: relative;
, and make other button positionabsolute
with left value width of input + spacing, and also give negativez-index
to go behind the search input.Something like this:
Note: Also use lowercase for html tags, it’s a good practice. Refer this SO question for more info.