gpt4 book ai didi

css - 在两个 div 之间创建可调整大小的边框

转载 作者:行者123 更新时间:2023-11-28 18:31:41 26 4
gpt4 key购买 nike

在 header 之后,我有一个 div,其中包含另外两个彼此相邻的 div。我想在它们之间创建一个边界。我试过使用左 div 的右边框或右 div 的左边框,但它们无法正常工作。

右边的div可以有很多内容,所以我必须为它做overflow: hidden,这样我才能滚动页面。但是如果我只有很少的内容,div 将不会垂直填充整个页面,所以左边框会很小。这里 -> http://www-user.tu-cottbus.de/~carbusor/Red%20Diamond/html/index.html你可以明白我在说什么。

当右边的 div 垂直增加时,我希望边框到底部,以跟随它的大小。

HTML:

<div id="wrapper">
<div id="leftsidebar">
<form id="logoutForm" action="index.html">
<h1 id="login_title">Logout</h1>
<fieldset id="actions">
<input id="logout" type="submit" value="Log out" />
</fieldset>
</form>
</div>
<div id="main">
<span id="location">Home</span>
<a href="member_news.html" class="normal_link">News</a>
</div>
</div>

CSS:

div#wrapper{
position:absolute;
top:25%;
width:100%;
}

div#leftsidebar{
/*position:absolute;
top:25%;*/
width:19.87%;
height:100%;
min-width:200px;
float:left;
}

div#main{
/*position:absolute;
top:25%;
left:20%;*/
/*width:79.81%;
float: left;*/
font-size:1.2em;
border-left-color:white;
border-left-style:solid;
border-left-width:3px;
overflow:hidden;
padding-bottom:2%;
}

我怎样才能得到我想要的东西?

最佳答案

为包装器和主 div 提供正确的高度,您将得到结果。

div#wrapper{
position:absolute; /*Stayed this whay cause you needed it*/
top:25%;
height: 75%; /**Make the wrapper contain all the needed space*/
width:100%;
}
div#main{
height:96%;
/**Value actually needs be a bit less then 100 due to padding*/
.... /**You're code here*/
}​

您可以在以下 jsFiddle 上看到操作结果。 http://jsfiddle.net/pY6nF/

关于css - 在两个 div 之间创建可调整大小的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14093893/

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