gpt4 book ai didi

HTML、CSS : Input Box Goes Outside of Viewable Area

转载 作者:太空宇宙 更新时间:2023-11-04 03:31:50 25 4
gpt4 key购买 nike

我有一些 div 和输入框。当我调整窗口大小时,div 会适当调整,但输入会被剪裁。如何在最大宽度为 400 像素的情况下将输入调整为屏幕大小?下面是两种状态的截图:Looks good .但是当页面变窄时,div 响应但是 the input gets cut but the divs are good .

这是我输入的样式

.text-input {
display: block;
width: 100%;
font-family: sans-serif;
font-size: 1em;
appearance: none;
border-radius: none;
padding: 0.5em;
border: solid 1px #fff;
box-shadow: inset 1px 1px 2px 1px #707070;
transition: box-shadow 0.3s;
max-width: 400px;
display: inline-block;
}
.text-input:focus,
.text-input.focus {
outline: none;
box-shadow: inset 1px 1px 2px 1px #c9c9c9;
}

我的问题是,我应该如何设置输入的样式以使其与 div 的行为相同?还请问解决方案背后的直觉是什么?

最佳答案

你可以把input放在一个div里面,给input一个width:100%;

HTML

<div>
<input type="text" />
</div>

CSS

input[type=text] {
width: 100%;
max-width: 400px;
box-sizing: border-box;
}
div {
border: solid 1px red
}

DEMO

关于HTML、CSS : Input Box Goes Outside of Viewable Area,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26193932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com