Slick Carousel (Next/Prev Button Placement) - html

Slick Carousel (Next/Prev Button Placement)
<div class="container">
<div id="carousel" class="carousel">
<div class="item red"></div>
<div class="item orange"></div>
<div class="item green"></div>
<div class="item blue"></div>
</div>
</div>
$('#carousel').slick({
arrows: true,
slidesToShow: 3
});
Link
Everything is working fine , but i wanted to ask is that how do i make the Next Previous button are placed in the box instead of outside (see example below)
What I wanted:
The Button is on the image (like the example below) - DONE + a button with opacity when user hover
Example :

you should add first this style
First-Step
.slick-prev, .slick-next {
top: auto;
bottom: 25px;
right: 35px;
z-index: 10;
}
Second-Step
.slick-prev {
left: 30px;
}
Third-Step
.slick-next {
right: 30px;
}

Everybody else already gave you the right answer, but since there seems to be something wrong with JS Fiddle right now, I'll throw the code in a snippet for you.
Also, due to the way these snippets include the CSS, the Slick styles were overwriting the ones added here. So I had to make them !important.
$('#carousel').slick({
arrows: true,
slidesToShow: 3
});
.slick-prev::before, .slick-next::before { color: black; }
.container {
width: 600px;
margin-left: 20px;
}
.carousel {
width: 100%;
border: 1px solid black;
}
.item, .content { height: 200px !important; }
.red { background: red; }
.orange { background: orange; }
.green { background: green; }
.blue { background: blue; }
.carousel-2 .item { margin-right: 15px; }
.carousel-3 .item .content { margin-right: 15px; }
/* Not CSS for carousel, but CSS to get the look I want Slick to manage automatically for me. */
.carousel-4 .item {
float: left;
margin-right: 15px;
width: 180px;
}
.carousel-4 .item:nth-child(3) { margin-right: 0; }
.slick-prev, .slick-next {
top: auto !important;
bottom: 0 !important;
z-index: 10 !important;
opacity: 0.5 !important;
}
.slick-next {
right: 0 !important;
}
.slick-prev {
left: 0 !important;
}
.slick-prev:hover, .slick-next:hover {
opacity: 1 !important;
}
<link href="https://cdn.jsdelivr.net/jquery.slick/1.3.6/slick.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://kenwheeler.github.io/slick/slick/slick.js"></script>
<!-- Standard carousel where Slick calculated the best widths to fit. -->
<div class="container">
<div id="carousel" class="carousel">
<div class="item red"></div>
<div class="item orange"></div>
<div class="item green"></div>
<div class="item blue"></div>
</div>
</div>

Looking at your sketch, add the following CSS classes:
.slick-prev {
left: 10px;
top: 180px;
z-index: 1000;
}
.slick-next {
right: 10px;
top: 180px;
z-index: 1000;
}
For the opacity on hover add:
.slick-prev:hover, .slick-next:hover {
opacity: 0.5;
}

.container .slick-arrow {
top: auto;
bottom: 0;
z-index: 100;
opacity: 0;
}
.container .slick-arrow:hover {
opacity: 1;
}
.container .slick-prev {
left: 0;
}
.container .slick-next {
right: 0;
}

Add the following to your css. You can change the 0 for bottom, right and left to whatever offset you'd like.
.slick-prev, .slick-next {
top:auto;
bottom: 0;
z-index: 10;
}
.slick-next {
right: 0;
}
.slick-prev {
left: 0;
}
.slick-prev:hover, .slick-next:hover {
opacity:0.5;
}
If you want to remove the extra space where the buttons used to be then change .container to the this:
.container { width: 570px; }

Fiddle
adding below styling to css will move arrows to location in your image.
/* to align arrow at bottom */
.slick-prev{
left: 10px;
z-index: 1;
top: 100%;
transform: translateY(-100%);
}
.slick-next{
right: 10px;
z-index: 1;
top: 100%;
transform: translateY(-100%);
}
if you want arrow to be opaced by default and visible on hover add below style.
/* to add opacity on default and remove it on hover */
.slick-prev,
.slick-next{
opacity: 0.5;
}
.slick-prev:hover,
.slick-next:hover{
opacity: 1;
}

Related

Make a paragraph appear inside a picture on picture hover

basically all i want to do is: Have a picture and when someone hovers over it i want some text to appear in its position(in the middle to be exact). What I have done so far is make the picture disappear on hover but i cannot get the text to be appeared..
Html:
<div class="container">
<img id="atp "class="atp" src="atp.jpg">
<div class="center">Some text</div>
</div>
Css:
atp{
display:block;
margin-left:auto;
margin-right:auto;
width:27%;
height:50%;}
container{
position: relative;
text-align: center;
}
.center{
position: absolute;
top:50%;
left:50%;
opacity: 0;
}
So basically, what i seek to be done is .atp:hover{opacity:0;} and what I also want is on atp's hover the .center{opacity:1;] So is there a way to put the opacity of center's to 1 when I am in the atp:hover{} code block?
Hope everything looks fine, thanks in advance!
Here is the code. Hope it will help you. if any changes please let me know.
/********* Simple or original overlay *******/
/* Main container */
.overlay-image {
position: relative;
width: 100%;
}
/* Original image */
.overlay-image .image {
display: block;
width: 100%;
height: auto;
}
/* Original text overlay */
.overlay-image .text {
color: #fff;
font-size: 30px;
line-height: 1.5em;
text-shadow: 2px 2px 2px #000;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
/********* Overlay on hover *******/
/* New overlay on hover */
.overlay-image .hover {
position: absolute;
top: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
}
/* New overlay appearance on hover */
.overlay-image:hover .hover {
opacity: 1;
}
/********* Background and text only overlay on hover *******/
.overlay-image .normal {
transition: .5s ease;
}
.overlay-image:hover .normal {
opacity: 0;
}
.overlay-image .hover {
background-color: rgba(0,0,0,0.5);
}
<div class="overlay-image">
<a href="LINK_URL">
<div class="normal">
<div class="text">Image + text ORIGINAL</div>
</div>
<div class="hover">
<img class="image" src="https://dummyimage.com/200x150/00ccff/fff.png" alt="Alt text hover" />
</div>
</a>
</div>
#atp {
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
width: 27%;
height: 50%;
z-index: 50;
}
.container {
position: relative;
text-align: center;
}
.center {
position: absolute;
top: 50%;
left: 50%;
z-index: 30;
}
#atp:hover {
opacity: 0;
}
try this, using z-index. It worked with me :)

Change background image on link hover pure CSS

I am trying to get this effect at my site. example:https://rno1.com/
(scroll down to "we specialize in")
I am very new to HTML and CSS also I am working on WordPress which make it a little bit harder.
started to code with this question here at StackOverflow:
Change body background image on hover with pure html/css
but I wanted to add a transition between the swapping images, also where do I need to change the font attributes?
div.link>a {
displya: inline-block !important;
position: relative !important;
z-index: 100;
}
.bg1:hover+.background {
background: url(https://aviel-albo.com/wp-content/uploads/2019/04/divorce-min.jpg);
}
.bg2:hover+.background {
background: url(https://aviel-albo.com/wp-content/uploads/2019/04/Fotolia_37279445_Subscription_Monthly_M-min.jpg);
}
.background {
background: transparent;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
<div class=container>
<div class="link">
bg1
<div class=background></div>
bg2
<div class=background>
</div>
</div>
</div>
You can add some opacity transition like below:
div.link>a {
display: inline-block;
position: relative;
z-index: 100;
}
.bg1+.background {
background: url(https://aviel-albo.com/wp-content/uploads/2019/04/divorce-min.jpg);
}
.bg1:hover +.background {
opacity:1;
}
.bg2+.background {
background: url(https://aviel-albo.com/wp-content/uploads/2019/04/Fotolia_37279445_Subscription_Monthly_M-min.jpg);
}
.bg2:hover +.background {
opacity:1;
}
.background {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
transition:1s all;
opacity:0;
}
<div class=container>
<div class="link">
bg1
<div class=background></div>
bg2
<div class=background>
</div>
</div>
</div>
You can also optimize your code like below:
div.link>a {
display: inline-block;
}
.bg1:before {
background: url(https://aviel-albo.com/wp-content/uploads/2019/04/divorce-min.jpg);
}
.bg1:hover:before {
opacity:1;
}
.bg2:before {
background: url(https://aviel-albo.com/wp-content/uploads/2019/04/Fotolia_37279445_Subscription_Monthly_M-min.jpg);
}
.bg2:hover:before {
opacity:1;
}
.bg:before {
content:"";
position: fixed;
z-index:-1;
width: 100%;
height: 100%;
top: 0;
left: 0;
transition:1s all;
opacity:0;
}
<div class=container>
<div class="link">
bg1
bg2
</div>
</div>

Parallax scroll bar below fixed container

I am trying to use the parallax effect on a site that has a fixed nav bar at the top of the page. Due to the way the parallax effect deals with overflows, the scroll bar appears to sit underneath the fixed nav bar at the top of the page.
I have included a fiddle to demonstrate this.
I have tried placing the fixed navbar div inside the parallax container. This moves the navbar beneath the scrollbar but also results in the navbar not fixing to the top of the page.
Here is my code so far...
HTML
<div class="navbar">NavBar</div>
<div class="parallax">
<div class="parallax_layer parallax_layer_back">
<img class="backgroundImage" src="https://images.pexels.com/photos/131212/pexels-photo-131212.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb">
</div>
<div class="parallax_layer parallax_layer_base">
<div class="title">Title</div>
<div class="content">Content area</div>
</div>
</div>
CSS
.parallax {
height: 100vh;
overflow-x: hidden;
overflow-y: initial;
perspective: 1px;
-webkit-perspective: 1px;
}
.parallax_layer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parallax_layer_base {
transform: translateZ(0);
-webkit-transform: translateZ(0);
}
.parallax_layer_back {
transform: translateZ(-1px);
-webkit-transform: translateZ(-1px);
}
.parallax_layer_back { transform: translateZ(-1px) scale(2); }
.parallax_layer_deep { transform: translateZ(-2px) scale(3); }
/* Example CSS for content */
* {
margin: 0;
padding: 0;
}
.title {
position: absolute;
left: 10%;
top: 30%;
color: white;
font-size: 300%;
}
.backgroundImage {
width: 100%;
height: auto;
}
.content {
margin-top: 100vh;
width: 100%;
height: 800px;
background-color: #e67e22;
}
.navbar {width:100%; position: fixed; z-index: 999; background-color: red;}
Based on your source code, I have made a few changes. I'll explain step by step.
Assume that your NavBar's height is 50px, I lower .parallax class 50px down by using margin-top:50px;.
Also, we need to change your NavBar's position property from fixed to absolute.
Now there will be 2 scrollbar, one for the body and one for the .parallax contents. To hide the body's scrollbar, which is unnecessary, we can use overflow:hidden; for body tag.
This time, you will see that your NavBar won't cover the scrollbar, but the bottom of the scrollbar is unfortunately unseeable since the contents is shifted 50px from to top. To solve this I use a simple Jquery code to set .parallax height equal to the remaining window's height.
You can have a look at the snippet.
$(document).ready(function(){
$(".parallax").css("height",$(window).height()-50);
});
.parallax {
margin-top:50px;
overflow-x: hidden;
overflow-y: initial;
perspective: 1px;
-webkit-perspective: 1px;
}
.parallax_layer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parallax_layer_base {
transform: translateZ(0);
-webkit-transform: translateZ(0);
}
.parallax_layer_back {
transform: translateZ(-1px);
-webkit-transform: translateZ(-1px);
}
/* Depth Correction */
.parallax_layer_back { transform: translateZ(-1px) scale(2); }
.parallax_layer_deep { transform: translateZ(-2px) scale(3); }
/* Example CSS for content */
* {
margin: 0;
padding: 0;
}
.title {
position: absolute;
left: 10%;
top: 30%;
color: white;
font-size: 300%;
}
.backgroundImage {
width: 100%;
height: auto;
}
.content {
margin-top: 100vh;
width: 100%;
height: 800px;
background-color: #e67e22;
}
.navbar {
width:100%;
position: absolute;
top:0;
z-index: 999;
background-color: red;
height:50px;
}
body{
overflow:hidden;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="navbar"> NavBar </div>
<div class="parallax">
<div class="parallax_layer parallax_layer_back">
<img class="backgroundImage" src="https://images.pexels.com/photos/131212/pexels-photo-131212.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb">
</div>
<div class="parallax_layer parallax_layer_base">
<div class="title">Title</div>
<div class="content">Content area</div>
</div>
</div>

In CSS how to set a different z-index property for two elements of the same class

I just don't come up with an idea how to do the following:
In my html-document i have two elements of the class "modal" (the bootstrap modal class).
The one modal must have a z-index of -5 and the other 10.
How could I achieve this?I suppose that I could use IDs,but I have no idea how exactly to write the code...
Thank you !
Posting some code would be nice that way you can get a direct answer.
but yes use id's
<div class="theexampleclass">
<div id="example"></div>
<div id="example2"></div>
</div>
in css
#example {
z-index: -5;
}
#example2 {
z-index: 10;
}
div {
position: relative;
width: 50px;
height: 50px;
padding: 10px;
margin:5px auto;
border: 1px solid #000;
}
.fst {
top: 0;
left: 0;
z-index: 1;
background: rgba(0,120,0,0.75);
color:gold;
}
.snd {
bottom: 15px;
left: 50px;
z-index: 2;
background: rgba(0,0,190,0.75);
color:gold;
}
.trd {
bottom: 30px;
left: 0;
z-index: 3;
background: rgba(255,0,0,0.75);
color:gold;
}
<div class="fst"> 1st Div </div>
<div class="snd"> 2nd Div </div>
<div class="trd"> 3rd Div </div>
Its very straight forward. Just focus on Z-index properties as other properties are applied to enhance look and feel.
See below working example:
/*--CSS--*/
div {
position: relative;
width: 50px;
height: 50px;
padding: 10px;
border: 1px solid #000;
}
#a {
top: 0;
left: 0;
z-index: 1;
background: rgba(255,0,0,0.75);
}
#b {
top: -25px;
left: 25px;
z-index: 2;
background: rgba(0,255,0,0.75);
}
#c {
top: -50px;
left: 50px;
z-index: 3;
background: rgba(0,0,255,0.75);
}
<!--HTML-->
<div id="a"> A </div>
<div id="b"> B </div>
<div id="c"> C </div>
Demo Fiddle 1 : https://jsfiddle.net/nikdtu/LLepva6L/
Demo Fiddle 2 : http://jsfiddle.net/nikdtu/8yyn6qcq/

how to format links so that they are 25% of the viewport in all for corners?

I have successfully set up four divs so that they are 25% of the viewport, in each corner. Now I want to make them clickable links, so that I can apply background images that change upon hover.
Here's what I have:
html:
<div id="intro">
<div class="box topleft">
<h4 class="blockhead">link1</h4>
</div>
<div class="box topright">
<h4 class="blockhead">link2</h4>
</div>
<div class="box bottomleft">
<h4 class="blockhead">link3</h4>
</div>
<div class="box bottomright">
<h4 class="blockhead">link4</h4>
</div>
</div>
css:
#intro {
position: absolute;
width: 100%;
height: 100%;
}
.box {
position: inherit;
width: 50%;
height: 50%;
}
.box a:active,
.box a:link {
padding: 0;
background: none;
width: 100%;
height: 100%;
}
.box h4.blockhead {
position: absolute;
color: #ffffff;
padding: 5%;
}
.box.topleft h4.blockhead,
.box.topright h4.blockhead { bottom: 0 }
.box.topleft h4.blockhead,
.box.bottomleft h4.blockhead { right: 0 }
.box.topleft {
background: #bad80a;
top: 0;
left: 0;
}
.box.topright {
background: #0083d6;
top: 0;
right: 0;
}
.box.bottomleft {
background: #003f87;
bottom: 0;
left: 0;
}
.box.bottomright {
background: #ffc61e;
bottom: 0;
right: 0;
}
It's imperative that the text in the divs remain aligned as they are. ANY help in the right direction greatly appreciated.
And here it is on jsfiddle: http://jsfiddle.net/blackessej/j47Ye/3/
.box a:link {
/* rest of code */
display: block;
}
http://jsfiddle.net/j47Ye/1/
What you need to use is display:inline-block;. inline-block works like the block attribute, but it keeps everything on the same line. Using block in this case may work, as shown by Miljan, but it is not proper. So I would just add something like
.box a {
display:inline-block;
}
Then you should be good to go
JSFiddle