Reputation: 169
I am practicing HTML and CSS. I have a question related to the following code-
.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>
Now, when I am resizing the browser window to the minimum, little bit of blue div is shown. Why is that and how can I fix it?
Thanks in advance!
Upvotes: 0
Views: 675
Reputation: 1370
Add
input[type="text"]{
position:absolute;
border:none;
}
.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>
Upvotes: 1