Reputation: 3181
I am using Unslider to display some content on my website. It works great, but unfortunately, the first slide is off when the page loads (the height is 310px when it should be 110px).
It also renders the page before the Unslider code takes effect, which is most likely the reason for the aforementioned height issue. I stopped the rendering of the page, and the height of the <li>
element is 310px before the unslider code resizes it upon revisiting the slide.
I would like to prevent both the "pre-rendering" and the resulting improper height of the first slide.
To illustrate the example visually, this is what occurs initially:
[TITLE 1]
[SLIDE 1 CONTENT] [IMAGE 1]
[TITLE 2]
[SLIDE 2 CONTENT] [IMAGE 2]
...etc (note visual width/height)
then, after half a second of loading time, it will properly show the slides (which also corrects the width):
[TITLE 1] [IMAGE 1]
[SLIDE 1 CONTENT]
height maintained
The code I have is as follows:
.hp_slideshow {
position: relative;
overflow: auto;
width:592px;
}
.hp_slideshow ul { padding: 0; }
.hp_slideshow li {
list-style: none;
position: relative;
width: 100%;
padding: 0;
}
.hp_slideshow ul li { float: left; }
$(function() {
$('.hp_slideshow').unslider({
dots: true,
delay: 4000,
keys: true
});
});
<div class="hp_slideshow">
<ul>
<li>
<img style="float:right;"/>
<h2>Title</h2>
<p>Content</p>
</li>
(repeat for 5 slides)
</ul>
</div>
Upvotes: 2
Views: 2815
Reputation: 4549
Yes i got the way,
unslider looking its li tag where it defines a vector for deceiding its width and height. something like below,
<li>
<img src="CMS/Files/slider_01.jpg" alt="" style="width: 105%; height: 980px;" />
<div class="widthfix">
<div>
<a>
<h2>Huzurunuz icin koruyoruz..</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus libero quam, blandit sed hendrerit molestie, rhoncus in velit.</p>
</a>
</div>
</div>
</li>
if you use a tag without a new div it doesnt know where its position linking to the its image container or other elements. The main reason about is that i think prepared to all browser supporting for responsive design.
Upvotes: 0
Reputation: 7011
I had the same issue, and found more than one solutions:
CSS
.slider ul {
height: 450px
}
HTML
<div class="slider">
<ul>
<li><img src="slider1.png" height="450" />
</ul>
</div>
CSS
.slider ul {
min-height: 450px
}
The second one is a bit since it's using the height
attribute, but it allows you to dynamically set the first banner's height from code. This can be useful in cases when you don't know in advance the height of the first slider, or if it changes often based on what the users upload.
Upvotes: 1
Reputation: 502
I am also face this issue. I have fixed to add "height" in the ul.
CSS
.hp_slideshow ul { height: px!important;}
Upvotes: 3