[英]Make right div resizable
I have two divs in another div container on the page. 我在页面上的另一个div容器中有两个div。 I want to make first div fix width and the second div rsizable.
我想使第一个div固定宽度和第二个div可调整大小。
<div id="container">
<div id="first"></div>
<div id="second">
<input id="edit" />
</div>
</div>
CSS: CSS:
#first {
width: 140px;
height: 50px;
float:left;
}
#second
{
position: absolute;
left: 140px;
width: 100%;
}
#container {
width: 100%;
position:relative;
}
But in this case the second div go out from the container on the right side. 但是在这种情况下,第二个div从右侧的容器中移出。 How to make second div resizable started from the right side of the first div to the end of container.
如何使第二个div可调整大小是从第一个div的右侧到容器的结尾。
Try this. 尝试这个。 https://jsfiddle.net/o7e5x0p0/2/
https://jsfiddle.net/o7e5x0p0/2/
#first {
width: 25%;
height: 50px;
float: left;
background: red;
}
#second {
float: left;
height: 50px;
width: 75%;
background: green;
}
input {
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
You can do this with Flexbox . 您可以使用Flexbox做到这一点 。 With
flex: 1;
使用
flex: 1;
on #second
div, it will take rest of space on right. 在
#second
div上,它将占用右侧的其余空间。 Fiddle 小提琴
#container { display: flex; } #first { width: 150px; background: blue; } #second { flex: 1; background: #939A9F; } #second input { width: 100%; }
<div id="container"> <div id="first"></div> <div id="second"> <input type="text"> </div> </div>
Or you can do this with CSS table Fiddle 或者您可以使用CSS表 Fiddle
#container { display: table; width: 100%; } #first { width: 150px; background: blue; display: table-cell; } #second { background: #939A9F; display: table-cell; } #second input { width: 100%; }
<div id="container"> <div id="first"></div> <div id="second"> <input type="text"> </div> </div>
in second
div change all to overflow: hidden
and input
width: 100%
: 在
second
div中,全部更改为overflow: hidden
, input
width: 100%
:
#first {
width: 140px;
height: 50px;
float: left;
}
#second {
overflow: hidden;
}
input {
width: 100%;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.