简体   繁体   English

如何设置部分流畅的布局(IMAGE)

[英]How to set up partially fluid layout (IMAGE)

I have a problem with setting up a layout for my design. 我在为设计设置布局时遇到问题。

I want to have two div's, left and right. 我想有两个div,左和右。 And i want them to fill left and right side, but stay in the same position in the center. 我希望它们填充左侧和右侧,但保持在中心位置不变。

Left div will have content only in "always visible" 300px (this page in not for mobile). 左div仅在“始终可见”的300px中显示内容(此页面不适用于移动设备)。 But in right DIV I want to have content based on %, to expand with larger screens. 但是在正确的DIV中,我希望基于%的内容可以在更大的屏幕上扩展。 And on the smaller screens I don't want to have w horizontal scroll bar at the bottom. 在较小的屏幕上,我不想在底部有水平滚动条。

Can someone point me to the best solution? 有人可以指出我的最佳解决方案吗?

Many thanks! 非常感谢!

在此处输入图片说明

FIDDLE 小提琴

Html will be : HTML将是:

<div class="left">Test</div>
<div class="right">Test</div>

CSS will be : CSS将是:

.left {width:300px; background:#FF0000; min-height:400px; float:left; }
.right { background:#00FF00; min-height:400px;  }

I think I came up with a solution. 我想我想出了一个解决方案。 So, HTML : 因此,HTML:

<div class="left"></div>
<div class="right"></div>

Css: CSS:

.left { 

  width:300px;
  position:fixed;
  top:0px;
  left:0px;
  height:100%;
  background:blue;

}

.right {
  width:900px;
  background:red;
}

JavaScript : JavaScript:

$(window).ready(function() {
            var hWind = $(window).height();
            var wWindow = $(window).width();
            var toDistribute = wWindow - 1200;
            if (toDistribute > 0) {


                var addToBoth = toDistribute/2;
                var lW = $('.left').width();
                var rW = $('.right').width();
                $('.left').width(lW+addToBoth);
                $('.right').width(rW+addToBoth);
                $('.right').css('margin-left',lW+addToBoth);
            }
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM