简体   繁体   English

Lush Slider全宽和限制高度

[英]Lush Slider full width and restricted height

I believe I have tried about everything and am failing miserably. 我相信我已经尝试过所有的事情而且我的失败是悲惨的。 I have been working with the lush responsive slider and have been having some major issues. 我一直在使用郁郁葱葱的响应滑块,并且遇到了一些重大问题。

To start off I took the exact code from the demo and placed it in my header, but it had a strange padding on the bottom and right side so I removed it and thought it was working fine except for the height. 首先,我从演示中取出了确切的代码并将其放在我的标题中,但它在底部和右侧有一个奇怪的填充因此我将其删除并认为除了高度之外它工作正常。 It's so large that it takes over more than half the page. 它太大了,占用了一半以上的页面。

When I resized the window and reloaded the page though the background of the slider sat in the top left corner much smaller than it needed to be. 当我调整窗口大小并重新加载页面时,滑块的背景位于左上角,比所需要的要小得多。 So the responsiveness only works if you reload at 100% screen? 因此,只有在100%屏幕重新加载时,响应能力才有效吗? That doesn't make any scenes. 这没有任何场景。

Also, the height is bothering me. 而且,高度困扰着我。 I cannot get it to resize at all and when I did put static heights on the ul and li of 10em it did resize, but then the responsiveness went out the window. 我根本无法调整大小,当我确实将静态高度放在10em的ul和li上时,它确实调整了大小,但随后响应性消失了。

I tried to post this in a js fiddle, but the plugin was so much code that it crashed it without running anything. 我尝试在js小提琴中发布这个,但插件是如此多的代码,它崩溃它没有运行任何东西。 If it would help I can post a dev site with this on it. 如果它有帮助我可以在其上发布一个开发站点。 As I said I used the exact html and css from the demo files I only took away a bit of padding to make it full width. 正如我所说,我使用了演示文件中的确切html和css,我只拿了一点填充来使其全宽。

Any help would be much appreciated. 任何帮助将非常感激。

Ok, I have managed to work out a solution for the width issue. 好的,我已经设法找到宽度问题的解决方案。 The problem seems to relate to the initial baseWidth, which defaults to 1140 pixels. 该问题似乎与初始baseWidth有关,默认为1140像素。 Playing around with the 玩弄着

data-base-width="600" and data-base-height="600" 

attributes in the first lush slider div tag may see you make some progress, but it looks like only fixed values are accepted, no percentages. 第一个郁金香滑块div标签中的属性可能会看到您取得了一些进展,但看起来只接受固定值,没有百分比。 I opted for this solution which seems to work, write the first div tag using document.write method and programmaticaly set the width the the clientWidth, as such : 我选择了这个似乎有效的解决方案,使用document.write方法编写第一个div标签,programmaticaly设置clientWidth的宽度,如下:

<script>
document.write('<div id="lushDiv" class="lush-slider autoload shadow-a" data-slider-pause-on-hover="true" data-base-width="' + document.body.clientWidth + '" data-base-height="600" style="background: rgb(229, 229, 229)">');
</script>

My suggestion is not to use Javascript or JQuery. 我的建议是不要使用Javascript或JQuery。 Some simple CSS and HTML will do. 一些简单的CSS和HTML都可以。

Here is the fiddle: http://jsfiddle.net/jacobdubail/bKaxg/7/ 这是小提琴: http//jsfiddle.net/jacobdubail/bKaxg/7/

You obviously don't need all of the CSS. 你显然不需要所有的CSS。 Just change it to accompany your layout. 只需更改它以配合您的布局。

Change your width to percentages, like so: 将宽度更改为百分比,如下所示:

min-width: 100%;

I would suggest changing the height to ems. 我建议将高度改为ems。

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

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