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

标签 html css

我正在练习 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/

相关文章:

html 和 css 边距自动错误

javascript - 根据数据属性如何隐藏标签并显示在另一个 div 中

javascript - 我正在尝试使用 css 高度栏通过排序数字更新 DOM

css - 如何防止一个 div 影响另一个 Bootstrap 表单元素的垂直位置?

html - 页脚不在内容的末尾

ajax 调用后 JavaScript 不工作

html - 如何让屏幕阅读器不将元素识别为元素组?

jquery - 在 vuejs 中使用列表框的数据绑定(bind)问题

javascript - 自定义plotly.js图例的外观

javascript - 使用 Bootstrap 下拉菜单显示/隐藏容器?