Reputation: 21
Here's an Illustration of what I need.
On the left a fixed div and on the right a horizontally scrolling div that is something like 12000px. I need the right div to center vertically in the window when it is re-sized. I can't get the usual tags I use (position:relative and margin:auto) to work on this. I assume it's because the div overflows on the sides of the screen?
Upvotes: 2
Views: 383
Reputation: 18785
Both the width and height are percentage-based (although you can change either to any other type of length that you would like). If you change the width
of the left column, be sure to change the left
of the right column to be the same. The vertical positioning is done with the top:0;bottom:0;margin:auto 0;height:70%;
. Positioning, top/bottom margin, and height must all be set in order for it to work.
Here's the jsFiddle Demo.
<div id="lc"></div>
<div id="rc">Here's some text that does not wrap. This would be replaced with images, of course.</div>
<style>
html, body {height:100%;}
#lc {position:fixed; top:0px; left:0px; width:20%; height:100%; background:lime;}
#rc {background:red; height:75%; position:fixed; left:20%;right:0;top:0; bottom:0;margin:auto 0;overflow-x:auto;overflow-y:hidden;white-space:nowrap;}
</style>
Note: Be sure to set the height
of all elements from html
to #lc
/#rc
's parent nodes to 100%
.
Upvotes: 0
Reputation: 47934
I'm not at all good at laying out pages, but this CSS is what you want for the left, horizontally scrolled, div
,
.horizontal_scroll{
float:left;
overflow:auto;
white-space: nowrap;
width : 500px;
height : 500px;
}
and applied to the div
,
<div class="horizontal_scroll"> ... </div>
Upvotes: 0