5 回答

TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個(gè)贊
因?yàn)樗?container已經(jīng)是一個(gè)顯示設(shè)置為 flex 的元素。您可以將所有 It 子項(xiàng)對(duì)齊在同一行上,并將輸入字段設(shè)置為增長(zhǎng)并占用容器內(nèi)的所有空間。
之后,您可以將背景顏色應(yīng)用于容器而不是將其應(yīng)用于輸入字段。
.container{
display: flex;
width: 500px;
justify-content: center;
align-items: center;
margin: 0 auto;
background-color: #fce6ef;
border-radius: 50px;
border: 1px solid #ffc5dd;
height: 60px;
padding: 0px 3px 0px 8px;
}
input{
padding: 4px;
flex-grow: 1;
background-color: transparent;
outline: none;
border: none;
margin-right: 8px;
}
button{
height: 54px;
width: 94px;
background-color: #ff0266;
color: #ffffff;
text-transform: uppercase;
border-style: none;
border-radius: 50px;
}
<div class="container">
<input type="text">
<button>Submit</button>
</div>

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超21個(gè)贊
考慮以下(沒(méi)有positioning):
.container {
display: flex;
width: 500px;
padding: 4px;
padding-left: 20px;
justify-content: center;
align-items: center;
margin: auto;
background-color: #fce6ef;
border-radius: 50px;
border: 1px solid #ffc5dd;
}
input {
width: 100%;
height: 54px;
background: none;
border: 0;
padding: 0;
outline: none;
}
button {
height: 54px;
width: 94px;
background-color: #ff0266;
color: #ffffff;
text-transform: uppercase;
border-style: none;
border-radius: 50px;
cursor: pointer;
outline: none;
}
<div class="container">
<input type="text">
<button>Submit</button>
</div>

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊
您可以通過(guò)設(shè)計(jì)而.container不是input. 然后使input透明,就是這樣:
.container {
display: flex;
width: 300px;
justify-content: center;
align-items: center;
padding: 2px;
background-color: #fce6ef;
border-radius: 50px;
border: 1px solid #ffc5dd;
}
input {
height: 54px;
font-size: 20px;
width: 100%;
background-color: transparent;
border-radius: 50px 0 0 50px;
border: none;
outline: none;
}
button {
height: 54px;
width: 94px;
background-color: #ff0266;
color: #ffffff;
text-transform: uppercase;
border-style: none;
border-radius: 50px;
}
<div class="container">
<input type="text">
<button>Submit</button>
</div>

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超4個(gè)贊
你不能在技術(shù)上把它放在輸入里面,但你可以絕對(duì)定位在輸入里面 position: absolute 在按鈕上和 position relative 在容器上。然后將其放置在頂部、左側(cè)、右側(cè)等位置。
<style>
.container{
display: flex;
width: 500px;
justify-content: center;
align-items: center;
margin: 0 auto;
position: relative;
}
input{
height: 60px;
width: 320px;
background-color: #fce6ef;
border-radius: 50px;
border: 1px solid #ffc5dd;
}
button{
height: 54px;
width: 94px;
background-color: #ff0266;
color: #ffffff;
text-transform: uppercase;
border-style: none;
border-radius: 50px;
position: absolute;
}
</style>
<body>
? ? <div class="container">
? ? ? <input type="text" /> <!-- close the input tag -->
? ? ? <button>Submit</button>
? ?</div>
</body>

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超3個(gè)贊
試試這個(gè)哥們 希望這是你需要的。我所做的只是使輸入透明,并使外部 div 保持輸入所具有的樣式。
編輯。擺脫了單擊元素時(shí)自然出現(xiàn)的可怕輸入輪廓。
.container{
? ? display: flex;
? ? justify-content: space-between;
? ? width: 500px;
? ? justify-content: center;
? ? align-items: center;
? ? margin: 0 auto;
? ? background-color: #fce6ef;
? ? border-radius: 50px;
? ? border: 1px solid #ffc5dd;
}
input{
? ? height: 58px;
? ? width: 100%;
? ? background-color:#fce6ef;
? ? border-radius: 50px;
? ? border: none;
}
button{
? ? height: 54px;
? ? width: 150px;
? ? background-color: #ff0266;
? ? color: #ffffff;
? ? text-transform: uppercase;
? ? border-style: none;
? ? border-radius: 50px;
}
input:focus {
? outline: none;
}
添加回答
舉報(bào)