gpt4 book ai didi

html - 屏幕小的时候输入框不会填满整个空间

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

我正在练习 HTML 和 CSS。我有一个与以下代码相关的问题-

.outer_class{
position: absolute;
width: 50%;
height: 30%;
top: 35%;
left: 25%;
background-color: red;
}
.inner_class{
position: relative;
width: 50%;
height: 50%;
top: 25%;
left: 25%;
background-color: yellow;
}
.div_input{
position: relative;
width: 70%;
height: 50%;
top: 25%;
left: 15%;
background-color: blue;
}
input[type="text"]{
box-sizing: border-box;
width: 100%;
height: 100%;

}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Align_Textbox_To_Div_Center</title>
<!--++++++++++++++++++++++Bootstrap CDN(Content Delivery Network)++++++++++++++++++++++++++++++-->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

</head>
<body>
<div class="outer_class">
<div class="inner_class">
<div class="div_input">
<input type="text" name="username">
</div>
</div>
</div>
</body>
</html>

现在,当我将浏览器窗口调整到最小时,会显示一点蓝色 div。为什么会这样,我该如何解决?

提前致谢!

最佳答案

添加
输入[类型=“文本”]{ position:absolute; 边框:无;

.outer_class{
position: absolute;
width: 50%;
height: 30%;
top: 35%;
left: 25%;
background-color: red;
}
.inner_class{
position: relative;
width: 50%;
height: 50%;
top: 25%;
left: 25%;
background-color: yellow;
}
.div_input{
position: relative;
width: 70%;
height: 50%;
top: 25%;
left: 15%;
background:blue;
}
input[type="text"]{
box-sizing: border-box;
width: 100%;
height: 100%;
position:absolute;
border:none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Align_Textbox_To_Div_Center</title>
<!--++++++++++++++++++++++Bootstrap CDN(Content Delivery Network)++++++++++++++++++++++++++++++-->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

</head>
<body>
<div class="outer_class">
<div class="inner_class">
<div class="div_input">
<input type="text" name="username">
</div>
</div>
</div>
</body>
</html>

关于html - 屏幕小的时候输入框不会填满整个空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39674773/

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