[英]Half fixed, half scrollable layout that can be scrolled… CSS
我有一个异国情调的设计需要以下。 左侧必须滚动,而右侧+顶部头必须保持(固定)。 见附图。
我可以通过位置来完成这个:固定在顶部和右侧。 左侧滚动时顶部和右侧保持放置.... 但是问题是,如果任何人放大并且您也无法从左向右滚动以查看整页,则没有滚动条
怎么会攻击这样的布局?
谢谢。
以前无法发布代码 - 让我再试一次:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Exotic</title>
<style type="text/css">
#top {
background-color: #FF0;
width: 1800px;
height: 50px;
position: fixed;
left: 0px;
top: 0px;
}
#sideLeft {
float: left;
width: 950px;
background-color: #9C0;
clear: left;
}
#sidebarLeft {
background-color: #0CC;
height: 800px;
width: 300px;
float: left;
}
.list {
float: left;
width: 600px;
margin-top: 100px;
}
#ordoner {
background-color: #F90;
float: left;
width: 640px;
height: 800px;
position: fixed;
top: 50px;
left: 950px;
}
#sidebarRight {
width: 210px;
height: 800px;
position: fixed;
top: 50px;
left: 1590px;
background-color: #0CF;
}
</style>
</head>
<body>
<div id="top">
</div>
<div id="sideLeft">
<div id="sidebarLeft"><!--end #sidebarLeft--></div>
<div class="list"><!--end .lisist--></div>
<!--end #sideLeft--></div>
<div id="ordoner"><!--end #ordoner--></div>
<div id="sidebarRight"><!--end #sidebarRight--></div>
<div id="footer"></div>
</body>
</html>
澄清:我的css在右侧反映了两件事,但重点是右侧和顶部应该是静态的,而左侧滚动......如果用户放大,它们应该是水平可滚动的:)
此外,我已经尝试将东西包装在容器div中,但这有其自身的问题 - 如果窗口未最大化,它会滚动但不会到达右侧。
再次感谢。
澄清一下:作为一个示例来说明我的观点...请将stackoverflow窗口调整为水平屏幕大小的一半...现在看看如何从左向右滚动? 如果放大,您也可以从左向右滚动以查看整个页面。 好吧,在我的布局中,它在全屏浏览器模式下工作...一旦我调整底部的滚动条,根本不会出现,使用户无法水平滚动。 见下图
小提琴http://jsfiddle.net/moby7000/tWb3e/
创建这样的布局并不是很难。
我为你创造了一个,看到工作小提琴
HTML:
<div class="Container">
<div class="Header">
<p>The Header div height is not fixed (But he can be if you want it to)</p>
<p>This Layout has been tested on: IE10, IE9, IE8, FireFox, Chrome, Safari, Opera. using Pure CSS 2.1 only</p>
</div>
<div class="Content">
<div class="Wrapper">
<div class="RightContent">
<p>You can fix the width of this content.</p>
<p>if you wont, his width will stretch just as it needs to.</p>
</div>
<div class="LeftContent">
<p>this will scroll</p>
</div>
</div>
</div>
</div>
CSS:
*
{
margin: 0;
padding: 0;
}
html, body, .Container
{
height: 100%;
}
.Container:before
{
content: '';
height: 100%;
float: left;
}
.Header
{
margin-bottom: 10px;
background-color: #6ea364;
}
.Content
{
position: relative;
z-index: 1;
}
.Content:after
{
content: '';
clear: both;
display: block;
}
.Wrapper
{
position: absolute;
width: 100%;
height: 100%;
}
.Wrapper > div
{
height: 100%;
}
.LeftContent
{
background-color: purple;
overflow: auto;
}
.RightContent
{
background-color: orange;
float: right;
margin-left: 10px;
}
额外奖励:通过CSS的一点变化,您可以创建漂亮的滚动。 看到那个小提琴
编辑:如果你想的宽度值设置在左侧,这实际上是更大然后是车身尺寸(并有一个水平滚动),做到这一点是这样。
<div class="LeftContent">
<div style="width:1200px;"> <-- better to aplly the width from the CSS
..<The content>..
</div>
</div>
你有没有尝试过
overflow-y: scroll;
身体?
你需要添加overflow:auto;
到您要滚动的区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.