我可以制作一个以列为中心的 JQuery UI 布局吗
我是 JQuery UI 的新手,我已经获得了基本示例,其中布局一直延伸到页面边缘。我想要的是这种布局,但内容位于居中的列中,并且您可以看到每一侧的背景颜色。因此,我使用一些非常简单的 CSS 在外部添加了一个 div,如下所示:
.frame
{
width:900px;
margin:0 auto;
}
<div class="frame">
<div class="ui-layout-north">
</div>
<div class="ui-layout-center">
</div>
<div class="ui-layout-east">
</div>
<div class="ui-layout-west">
</div>
<div class="ui-layout-south">
</div>
唉,我没有像普通 div 那样工作,而是看到一个弹出窗口,上面写着:
UI布局初始化错误
中心窗格元素不存在。
中心窗格是必需的元素
为什么会这样做,我该如何修复它?
提前致谢,请记住,我可能会犯一个非常低级的错误。 :)
I am new to JQuery UI and I have gotten the basic example working where the layout goes all the way to the edge of the page. What I'd like is this layout, but where the content is in a centered column, and you can see the background color on each side. So I added a div to the outside with some very simple CSS, like so:
.frame
{
width:900px;
margin:0 auto;
}
<div class="frame">
<div class="ui-layout-north">
</div>
<div class="ui-layout-center">
</div>
<div class="ui-layout-east">
</div>
<div class="ui-layout-west">
</div>
<div class="ui-layout-south">
</div>
Alas, instead of working like a normal div, I get a pop-up that says:
UI Layout Initialization Error
The center-pane element does not exist.
The center-pane is a required element
Why does it do that, and how can I fix it?
Thanks in advance, and keep in mind, I may be making a very noobish error. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能仍在将
layout()
应用于文档正文:在这种情况下,布局引擎将找不到窗格元素,因为它们并不驻留在正文本身中。解决方案是将
layout()
应用于包装元素:
It might be that you're still applying
layout()
to the document body:In that case, the layout engine won't find the pane elements since they don't reside in the body itself. A solution would be to apply
layout()
to your wrapper<div>
element instead:根据您的最终目标,您可能想尝试扭转这一情况 - 将将布局居中的 div 放入
#ui-layout-center
中,并为其指定margin: 0 auto;
。Depending on your end goal, you might want to try reversing this - put the div that will center your layout inside
#ui-layout-center
and give itmargin: 0 auto;
.