Slick Slider Text On Top Of Images
I'm trying to make a pretty normal carousel, with two arrows on either side in the vertical middle, and text with a button in the middle on top of the image. I cannot get anything
Solution 1:
You have to do
.slick-slide {
/* ... */position: relative;
}
so that the .info
stuff knows it should be absolutely positioned to it's parent.
Solution 2:
Just add position: relative
to .slide-slide
.
jQuery(function($){
$('.slick-slider').slick({
accessibility: true,
adaptiveHeight: true,
arrows: true,
infinite: true,
mobileFirst: true,
nextArrow: '<div class="chevron-container slick-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span><span class="sr-only">Next</span></div>',
prevArrow: '<div class="chevron-container"><i class="fa fa-chevron-left" aria-hidden="true"></i></span><span class="sr-only">Previous</span></div>',
slidesToShow: 1
});
});
.slick-slider
{
position: relative;
display: block;
box-sizing: border-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-touch-callout: none;
-khtml-user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}
.slick-list
{
position: relative;
display: block;
overflow: hidden;
margin: 0;
padding: 0;
}
.slick-list:focus
{
outline: none;
}
.slick-list.dragging
{
cursor: pointer;
cursor: hand;
}
.slick-slider.slick-track,
.slick-slider.slick-list
{
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.slick-track
{
position: relative;
top: 0;
left: 0;
display: block;
}
.slick-track:before,
.slick-track:after
{
display: table;
content: '';
}
.slick-track:after
{
clear: both;
}
.slick-loading.slick-track
{
visibility: hidden;
}
.slick-slide
{
display: none;
float: left;
position: relative;
height: 100%;
min-height: 1px;
}
[dir='rtl'].slick-slide
{
float: right;
}
.slick-slideimg
{
display: block;
}
.slick-slide.slick-loadingimg
{
display: none;
}
.slick-slide.draggingimg
{
pointer-events: none;
}
.slick-initialized.slick-slide
{
display: block;
}
.slick-loading.slick-slide
{
visibility: hidden;
}
.slick-vertical.slick-slide
{
display: block;
height: auto;
border: 1px solid transparent;
}
.slick-arrow.slick-hidden {
display: none;
}
.slick-sliderimg { /* keep images full screen */width: 100%;
}
.chevron-container { /* full slider height container for chevrons */height: 100%;
position: absolute;
width: 100px;
}
.slick-right { /* keeps right arrow to the right */right: 0;
top: 0;
}
.chevron-container > .fa { /* positions chevrons in vertical center */bottom: 0;
color: white;
font-size: 10em;
height: 1em;
margin: auto;
position: absolute;
top: 0;
width: 5em;
z-index: 10;
}
.slick-slider.info {
color: white;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
line-height: 100vh;
text-align: center;
z-index: 10;
}
.slick-slider.info > div {
display: inline-block !important;
vertical-align: middle;
}
<linkhref="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"rel="stylesheet"/><scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><scriptsrc="http://kenwheeler.github.io/slick/slick/slick.js"></script><divclass="slick-slider"><div><imgclass="img-fluid"src="http://www.placecage.com/1500/750"alt=""><divclass="info"><h1class="slider-heading">Heading</h1><pclass="slider-subheading lead">Subheading</p><aclass="btn btn-large btn-danger"href="">button text</a><pclass="down-arrow"><aclass="btn btn-large btn-down-arrow"href="#theend"><iclass="fa fa-chevron-down fa-lg"aria-hidden="true"></i></a></p></div></div><div><imgclass="img-fluid"src="http://www.placecage.com/1500/750"alt=""></div><div><imgclass="img-fluid"src="http://www.placecage.com/1500/750"alt=""></div></div>
Post a Comment for "Slick Slider Text On Top Of Images"