CSS 布局:2 列固定流体(再次)
我正在尝试设置一个 2 列布局,其中左侧区域是固定的,主要内容是流动的。我在这里看到了几个答案,它们往往有效。然而,当我在“左侧”区域使用“jsTree”并在主/内容区域使用 jQuery UI 选项卡时,会出现一些奇怪的行为。
html
<div id="main">
<div id="left">
<div id="tree">
</div>
</div>
<div id="right">
<ul>
<li><a href="#a">A</a></li>
<li><a href="#b">B</a></li>
<li><a href="#c">C</a></li>
</ul>
<div id="a">
<h3>A is here</h3>
</div>
<div id="b">
<h3>B is here</h3>
</div>
<div id="c">
<h3>C is here</h3>
</div>
</div>
</div>
css
#left {
float: left;
width: 200px;
overflow: auto;
}
#right {
margin: 0 0 0 200px;
}
javascript
$(document).ready(function() {
$('#right').tabs();
$('#tree').jstree({
"plugins" : [ "json_data", "themes"],
"json_data" : {
"data" : [
{
"data" : "A node",
"children" : [ "Child 1", "Child 2" ]
},
{
"attr" : { "id" : "li.node.id" },
"data" : {
"title" : "Long format demo",
"attr" : { "href" : "#" }
}
}
]
},
});
});
我遇到的问题是,当我展开树(左侧)时,右侧的选项卡开始变得奇怪。包含选项卡的区域(我认为是元素)垂直增长。
看一下这里的示例:http://jsfiddle.net/codecraig/gBUw2/
I'm trying to setup a 2-column layout where the left area is fixed and the main content is fluid. I've seen several answers on here, which tend to work. However, there is some odd behavior when I use a "jsTree" in my "left" area and jQuery UI tabs in the main/content area.
html
<div id="main">
<div id="left">
<div id="tree">
</div>
</div>
<div id="right">
<ul>
<li><a href="#a">A</a></li>
<li><a href="#b">B</a></li>
<li><a href="#c">C</a></li>
</ul>
<div id="a">
<h3>A is here</h3>
</div>
<div id="b">
<h3>B is here</h3>
</div>
<div id="c">
<h3>C is here</h3>
</div>
</div>
</div>
css
#left {
float: left;
width: 200px;
overflow: auto;
}
#right {
margin: 0 0 0 200px;
}
javascript
$(document).ready(function() {
$('#right').tabs();
$('#tree').jstree({
"plugins" : [ "json_data", "themes"],
"json_data" : {
"data" : [
{
"data" : "A node",
"children" : [ "Child 1", "Child 2" ]
},
{
"attr" : { "id" : "li.node.id" },
"data" : {
"title" : "Long format demo",
"attr" : { "href" : "#" }
}
}
]
},
});
});
The problem I'm having is, as I expand the tree (on the left) the tabs on the right start getting funky. The area containing the tabs (the element I believe) grows vertically.
Take a look here for this example: http://jsfiddle.net/codecraig/gBUw2/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
约西亚说得对,但更好的解决方案是改变清晰修复技术的性质。
.ui-helper-clearfix
这样做:问题是
clear:both
。您可以通过以下方式获得所需的清除,而不会丢失全角块显示:将
clear:both
clear-fix 替换为overflow:hidden代码> 清除修复。
Josiah has it right but a better solution is to change the nature of the clear-fix technique. The
.ui-helper-clearfix
does this:And the problem is the
clear:both
. You can get the desired clearing without losing the full-width block display with this:That replaces the
clear:both
clear-fix with anoverflow:hidden
clear-fix.http://jsfiddle.net/ambiguous/BkWWW/
小部件选项卡标题有一个明确的修复。 更新了小提琴。您可以使用非浮动布局来修复此问题,或者像这样覆盖 css:
这使得标头不会扩展容器的整个宽度。
The widget tabs header has a clear fix. updated fiddle. You could fix this with a non float layout, or override the css like so:
This makes it so that the header does not expand the full width of the container however.
您需要做的就是简单地调整您的 css,如下所示:
这也可以解决选项卡容器不扩展整个宽度的问题。尽管您可以将 #right 的宽度百分比调整为您喜欢的任何值。
All you need to do is to simply tweak your css, like this:
This would also fix the issue that the tabs' container don't expand full width. Though you could tune the width percentage of #right to whatever you like.