[英]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.