Adding link to slides - carousel

I used this carousel from Codepen.
https://codepen.io/dangvanthanh/pen/AgHnB
I added links to each slide, but when I did, all the slides link to the link of the last slide. I even tried adding an onlick event onclick="window.location='https://codepen.io'" but without success.. Please help.
Fyi, Im a designer, not a front end developer, and Im just trying to put together a carousel for a website..
/**
* Carousel.sass
* #author: Dang Van Thanh
* #github: https://github.com/dangvanthanh/carousel.sass
* #description: A Simple Carousel Pure CSS Using Sass
* #version: 1.0.0
*/
.carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__prev > label:nth-child(5), .carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__next > label:nth-child(2), .carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__prev > label:nth-child(1), .carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__next > label:nth-child(3), .carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__prev > label:nth-child(2), .carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__next > label:nth-child(4), .carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__prev > label:nth-child(3), .carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__next > label:nth-child(5), .carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__prev > label:nth-child(4), .carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__next > label:nth-child(1) {
opacity: 1 !important;
z-index: 3;
}
*,
*:before,
*:after {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
body {
background: #fcfcfc;
margin: 0;
}
.container {
width: 900px;
min-width: 900px;
margin: 50px auto;
}
.carousel {
width: 100%;
position: relative;
overflow: hidden;
}
.carousel > input[type="radio"] {
position: absolute;
left: 0;
opacity: 0;
top: 0;
}
.carousel > input[type="radio"]:checked ~ .carousel__items .carousel__item,
.carousel > input[type="radio"]:checked ~ .carousel__prev > label,
.carousel > input[type="radio"]:checked ~ .carousel__next > label {
opacity: 0;
}
.carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__items .carousel__item:nth-child(1) {
opacity: 1;
}
.carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__nav > label:nth-child(1) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__items .carousel__item:nth-child(2) {
opacity: 1;
}
.carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__nav > label:nth-child(2) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__items .carousel__item:nth-child(3) {
opacity: 1;
}
.carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__nav > label:nth-child(3) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__items .carousel__item:nth-child(4) {
opacity: 1;
}
.carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__nav > label:nth-child(4) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__items .carousel__item:nth-child(5) {
opacity: 1;
}
.carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__nav > label:nth-child(5) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel__items {
margin: 0;
padding: 0;
list-style-type: none;
width: 100%;
height: 600px;
position: relative;
}
.carousel__item {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
transition: opacity 2s;
-webkit-transition: opacity 2s;
}
.carousel__item img {
width: 100%;
vertical-align: middle;
}
.carousel__prev > label, .carousel__next > label {
border: 1px solid #fff;
border-radius: 50%;
cursor: pointer;
display: block;
width: 40px;
height: 40px;
position: absolute;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
transition: all .3s ease;
-webkit-transition: all .3s ease;
opacity: 0;
z-index: 2;
}
.carousel__prev > label:hover, .carousel__prev > label:focus, .carousel__next > label:hover, .carousel__next > label:focus {
opacity: .5 !important;
}
.carousel__prev > label:before, .carousel__prev > label:after, .carousel__next > label:before, .carousel__next > label:after {
content: "";
position: absolute;
width: inherit;
height: inherit;
}
.carousel__prev > label:before, .carousel__next > label:before {
background: linear-gradient(to top, #fff 0%, #fff 10%, rgba(51, 51, 51, 0) 10%), linear-gradient(to left, #fff 0%, #fff 10%, rgba(51, 51, 51, 0) 10%);
width: 60%;
height: 60%;
top: 20%;
}
.carousel__prev > label {
left: 2%;
}
.carousel__prev > label:before {
left: 35%;
top: 20%;
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.carousel__next > label {
right: 2%;
}
.carousel__next > label:before {
left: 10%;
transform: rotate(315deg);
-webkit-transform: rotate(315deg);
}
.carousel__nav {
position: absolute;
bottom: 3%;
left: 0;
text-align: center;
width: 100%;
z-index: 3;
}
.carousel__nav > label {
border: 1px solid #fff;
display: inline-block;
border-radius: 50%;
cursor: pointer;
margin: 0 .125%;
width: 20px;
height: 20px;
}
<div class="container">
<div class="carousel">
<input type="radio" id="carousel-1" name="carousel[]" checked onclick="window.location.href='http://google.com'">
<input type="radio" id="carousel-2" name="carousel[]">
<input type="radio" id="carousel-3" name="carousel[]">
<input type="radio" id="carousel-4" name="carousel[]">
<input type="radio" id="carousel-5" name="carousel[]">
<ul class="carousel__items">
<li class="carousel__item" onclick="window.location='http://google.com'">
<a href"http://google.com">
<img src="//lh5.googleusercontent.com/-cTEgPOnd3l8/U8-EmaZ4KNI/AAAAAAAABc8/6eacbALkQ6A/w1358-h905-no/carousel-1.JPG" alt="" style="border: 3px solid red">
</a>
</li>
<li class="carousel__item">
<a href"http://instagram.com">
<img src="//lh4.googleusercontent.com/-ntVHbbWX5eo/U8-EmV8P4cI/AAAAAAAABc4/ICYBGkcztTc/w1358-h905-no/carousel-2.jpg" alt="">
</a>
</li>
<li class="carousel__item">
<a href"http://facebook.com">
<img src="//lh5.googleusercontent.com/-batEXUZE_e4/U8-EmLF9-hI/AAAAAAAABc0/J3tJVUa6Buk/w1358-h905-no/carousel-3.jpg" alt="">
</a>
</li>
<li class="carousel__item">
<a href"http://tiktok.com">
<img src="//lh5.googleusercontent.com/-gywqIeMvel0/U8-EolKdtkI/AAAAAAAABdM/G0-NHuvvJUU/w1358-h905-no/carousel-4.jpg" alt="">
</a>
</li>
<li class="carousel__item">
<a href"http://pinterest.com">
<img src="//lh5.googleusercontent.com/--2iANjL3ikc/U8-EoGJ18mI/AAAAAAAABdI/fBe-q3Gos6Y/w1358-h905-no/carousel-5.jpg" alt="">
</a>
</li>
</ul>
<div class="carousel__prev">
<label for="carousel-1"></label>
<label for="carousel-2"></label>
<label for="carousel-3"></label>
<label for="carousel-4"></label>
<label for="carousel-5"></label>
</div>
<div class="carousel__next">
<label for="carousel-1"></label>
<label for="carousel-2"></label>
<label for="carousel-3"></label>
<label for="carousel-4"></label>
<label for="carousel-5"></label>
</div>
<div class="carousel__nav">
<label for="carousel-1"></label>
<label for="carousel-2"></label>
<label for="carousel-3"></label>
<label for="carousel-4"></label>
<label for="carousel-5"></label>
</div>
</div>
</div>

There you go:
Codepen
You were seeing this behaviour bacause the transition was using the slide opacity so the last link will always be in the front.
/**
* Carousel.sass
* #author: Dang Van Thanh
* #github: https://github.com/dangvanthanh/carousel.sass
* #description: A Simple Carousel Pure CSS Using Sass
* #version: 1.0.0
*/
.carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__prev > label:nth-child(5), .carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__next > label:nth-child(2), .carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__prev > label:nth-child(1), .carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__next > label:nth-child(3), .carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__prev > label:nth-child(2), .carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__next > label:nth-child(4), .carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__prev > label:nth-child(3), .carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__next > label:nth-child(5), .carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__prev > label:nth-child(4), .carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__next > label:nth-child(1) {
opacity: 1 !important;
z-index: 3;
}
*,
*:before,
*:after {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
body {
background: #fcfcfc;
margin: 0;
}
.container {
width: 900px;
min-width: 900px;
margin: 50px auto;
}
.carousel {
width: 100%;
position: relative;
overflow: hidden;
}
.carousel > input[type="radio"] {
position: absolute;
left: 0;
opacity: 0;
top: 0;
}
.carousel > input[type="radio"]:checked ~ .carousel__items .carousel__item,
.carousel > input[type="radio"]:checked ~ .carousel__prev > label,
.carousel > input[type="radio"]:checked ~ .carousel__next > label {
opacity: 0;
z-index: -1;
}
.carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__items .carousel__item:nth-child(1) {
opacity: 1;
z-index: 1;
}
.carousel > input[type="radio"]:nth-child(1):checked ~ .carousel__nav > label:nth-child(1) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__items .carousel__item:nth-child(2) {
opacity: 1;
z-index: 1;
}
.carousel > input[type="radio"]:nth-child(2):checked ~ .carousel__nav > label:nth-child(2) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__items .carousel__item:nth-child(3) {
opacity: 1;
z-index: 1;
}
.carousel > input[type="radio"]:nth-child(3):checked ~ .carousel__nav > label:nth-child(3) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__items .carousel__item:nth-child(4) {
opacity: 1;
z-index: 1;
}
.carousel > input[type="radio"]:nth-child(4):checked ~ .carousel__nav > label:nth-child(4) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__items .carousel__item:nth-child(5) {
opacity: 1;
z-index: 1;
}
.carousel > input[type="radio"]:nth-child(5):checked ~ .carousel__nav > label:nth-child(5) {
background: #ccc;
cursor: default;
pointer-events: none;
}
.carousel__items {
margin: 0;
padding: 0;
list-style-type: none;
width: 100%;
height: 600px;
position: relative;
}
.carousel__item {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
transition: opacity 2s;
-webkit-transition: opacity 2s;
}
.carousel__item img {
width: 100%;
vertical-align: middle;
}
.carousel__prev > label, .carousel__next > label {
border: 1px solid #fff;
border-radius: 50%;
cursor: pointer;
display: block;
width: 40px;
height: 40px;
position: absolute;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
transition: all .3s ease;
-webkit-transition: all .3s ease;
opacity: 0;
z-index: 2;
}
.carousel__prev > label:hover, .carousel__prev > label:focus, .carousel__next > label:hover, .carousel__next > label:focus {
opacity: .5 !important;
}
.carousel__prev > label:before, .carousel__prev > label:after, .carousel__next > label:before, .carousel__next > label:after {
content: "";
position: absolute;
width: inherit;
height: inherit;
}
.carousel__prev > label:before, .carousel__next > label:before {
background: linear-gradient(to top, #fff 0%, #fff 10%, rgba(51, 51, 51, 0) 10%), linear-gradient(to left, #fff 0%, #fff 10%, rgba(51, 51, 51, 0) 10%);
width: 60%;
height: 60%;
top: 20%;
}
.carousel__prev > label {
left: 2%;
}
.carousel__prev > label:before {
left: 35%;
top: 20%;
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.carousel__next > label {
right: 2%;
}
.carousel__next > label:before {
left: 10%;
transform: rotate(315deg);
-webkit-transform: rotate(315deg);
}
.carousel__nav {
position: absolute;
bottom: 3%;
left: 0;
text-align: center;
width: 100%;
z-index: 3;
}
.carousel__nav > label {
border: 1px solid #fff;
display: inline-block;
border-radius: 50%;
cursor: pointer;
margin: 0 .125%;
width: 20px;
height: 20px;
}
<div class="container">
<div class="carousel">
<input type="radio" id="carousel-1" name="carousel[]" checked>
<input type="radio" id="carousel-2" name="carousel[]">
<input type="radio" id="carousel-3" name="carousel[]">
<input type="radio" id="carousel-4" name="carousel[]">
<input type="radio" id="carousel-5" name="carousel[]">
<ul class="carousel__items">
<li class="carousel__item"><img src="//lh5.googleusercontent.com/-cTEgPOnd3l8/U8-EmaZ4KNI/AAAAAAAABc8/6eacbALkQ6A/w1358-h905-no/carousel-1.JPG" alt=""></li>
<li class="carousel__item"><img src="//lh4.googleusercontent.com/-ntVHbbWX5eo/U8-EmV8P4cI/AAAAAAAABc4/ICYBGkcztTc/w1358-h905-no/carousel-2.jpg" alt=""></li>
<li class="carousel__item"><a href="https://www.yahoo.com">
<img src="//lh5.googleusercontent.com/-batEXUZE_e4/U8-EmLF9-hI/AAAAAAAABc0/J3tJVUa6Buk/w1358-h905-no/carousel-3.jpg" alt="">
</a></li>
<li class="carousel__item"><img src="//lh5.googleusercontent.com/-gywqIeMvel0/U8-EolKdtkI/AAAAAAAABdM/G0-NHuvvJUU/w1358-h905-no/carousel-4.jpg" alt=""></li>
<li class="carousel__item"><img src="//lh5.googleusercontent.com/--2iANjL3ikc/U8-EoGJ18mI/AAAAAAAABdI/fBe-q3Gos6Y/w1358-h905-no/carousel-5.jpg" alt=""></li>
</ul>
<div class="carousel__prev">
<label for="carousel-1"></label>
<label for="carousel-2"></label>
<label for="carousel-3"></label>
<label for="carousel-4"></label>
<label for="carousel-5"></label>
</div>
<div class="carousel__next">
<label for="carousel-1"></label>
<label for="carousel-2"></label>
<label for="carousel-3"></label>
<label for="carousel-4"></label>
<label for="carousel-5"></label>
</div>
<div class="carousel__nav">
<label for="carousel-1"></label>
<label for="carousel-2"></label>
<label for="carousel-3"></label>
<label for="carousel-4"></label>
<label for="carousel-5"></label>
</div>
</div>
</div>

Related

How to make a preloader for an image?

I have a picture
<img class="block" :src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/1024px-Google_%22G%22_Logo.svg.png" />
But how to show some other picture while the main one has not loaded?
<template> <div>
<img class="loading" v-if="pending" alt="image" /> <!-- This is a beautiful animation -->
<img src="your-image.png" v-if="pending" alt="image" /> <!-- If you want to put another optional picture you will do so -->
<img v-else :src="img" class="block" alt="image" /> </div>
</template>
<script>
export default {
data() {
return {
pending: false,
img: ''
};
},
created() {
this.pending = false
// your get request
fetch("https://example-api.com/image")
.then((data) => (this.img = data.img))
.finally(() => {
this.pending = false;
});
},
};
</script>
<style lang="scss">
.loading {
position: relative;
user-select: none;
cursor: wait;
transition: all 0.2s;
border-radius: 4px !important;
border: none;
background: transparent;
overflow: hidden;
color: transparent !important;
&:before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background-color: #e8ecf1 !important;
cursor: wait;
-webkit-mask-image: radial-gradient(white, black);
transition: all 0.2s;
}
&:after {
animation: loading 1.5s infinite;
content: "";
height: 100%;
left: 0;
position: absolute;
right: 0;
top: 0;
transform: translateX(-100%);
z-index: 1;
background: linear-gradient(
90deg,
rgba(255, 255, 255, 0),
rgba(255, 255, 255, 0.5),
rgba(255, 255, 255, 0)
);
}
svg {
opacity: 0;
}
}
</style>

Overlay on hover in vue.js

Im trying to implement displaying text when hovering over an image in vue.js but I am a bit stuck. Im trying to implement this example on an array with multiple images:
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_image_overlay_fade
I got a pretty big vue file but here is the essential:
template:
</template>
[...]
<div v-for="item in filteredPeople" v-bind:key="item.id" class="list-complete-item">
<router-link #mouseover.native="hovertext" :to="'/'+item.link">
<img class="list-complete-img" :src="'http://placehold.it/400x300?text='+item.id" alt>
</router-link>
</div>
[...]
</template>
script
<script>
export default {
data() {
return {
info: [
{
id: 1,
title: "Title one",
link: "project1",
hovertext: "project1 hover text lorem lorem lorem",
category_data: {
"1": "Category 1"
}
},
[...]
methods: {
hovertext() {
console.log("");
},
I had some idea to try to use a method to put the text in a div under the image but then I cannot get the text to get above the image on hover. And I cannot get the method right ... Not really sure this is a good way doing it,
I also found this codepen example:
https://codepen.io/oliviaisarobot/pen/xzPGvY
This is pretty close to what I want to do but I cannot get the text to display here either.
I am a bit lost. Any help how to do this in vue?
---------- UPDATE ----------
I want the image boxes to stretch so they always fits the window but I seems to get a gap between my flexbox rows which I cannot seem to get rid of. You can see the white space. I attach my stylesheet.
.list-complete {
display: flex;
height: auto;
flex-direction: row;
flex-flow: row wrap;
}
.list-complete-item {
flex: 0 1 50%;
display: inline-block;
}
.list-complete-item a {
display: inline-block;
position: relative;
width: 100%;
height: auto;
outline: 1px solid #fff;
}
.list-complete-img {
width: 100%;
}
.text {
color: rgb(186, 74, 74);
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.list-complete-item a:hover .overlay {
opacity: 1;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
height: 60%;
width: 100%;
opacity: 0;
transition: 0.5s ease;
background-color: #008cba;
}
You don't need to use js(vue) events. Do it with plain css, like in example you linked to.
Go with this template:
<div v-for="item in filteredPeople" v-bind:key="item.id" class="list-complete-item">
<router-link :to="'/'+item.link">
<img class="list-complete-img" :src="'http://placehold.it/400x300?text='+item.id" alt>
<div class="overlay">
<div class="text">{{ item.hovertext }}</div>
</div>
</router-link>
</div>
And style it up:
.list-complete-item {
width: 400px;
height: 300px;
display: inline-block;
}
.list-complete-item a {
display: inline-block;
position: relative;
width: 400px;
height: 300px;
}
.list-complete-item a .image {
display: block;
width: 100%;
height: auto;
}
.list-complete-item a .overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.list-complete-item a:hover .overlay {
opacity: 1;
}
.list-complete-item a .text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
And the final result:

css animation rotate while moving

am trying to create an animation that
scale
rotate
translate
but i cant understand why the rotation doesnt play well with translateX, am trying to get the animation to play in a continuous motion along the z-axis not like a swirl, i've searched alot but i couldnt find what am after so any help is appreciated.
function reRun() {
document.querySelector('.item').classList.remove('spin-animation')
setTimeout(function() {
document.querySelector('.item').classList.add('spin-animation')
},300)
}
#keyframes spin {
0% {
transform: scale(1) rotateY(0deg) translate(0, 0);
}
25% {
transform: scale(2) rotateY(360deg) translate(-1rem, -1rem);
}
50% {
transform: scale(3) rotateY(0deg) translate(-1.5rem, -1.5rem);
}
75% {
transform: scale(4) rotateY(360deg) translate(-2rem, -2rem);
}
100% {
transform: scale(5) rotateY(0deg) translate(-2.5rem, -2.5rem);
}
}
.spin-animation {
animation: spin 2s linear forwards;
}
.item {
position: absolute;
bottom: 1rem;
right: 1rem;
font-size: 2rem;
color: red;
}
.axis {
position: absolute;
right: 0.8rem;
bottom: 1.2rem;
}
.y-axis {
width: 1px;
height: 300px;
background: black;
position: absolute;
right: 0;
bottom: 0;
}
.x-axis {
width: 300px;
height: 1px;
background: black;
}
.z-axis {
width: 1px;
height: 300px;
position: absolute;
right: 0;
bottom: 0;
background: black;
transform: skewX(45deg);
transform-origin: right bottom;
}
.z-axis span {
padding: 0.5rem;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<button onclick="reRun()">ReRun the Example</button>
<div class="item spin-animation">
<i class="fa fa-question" aria-hidden="true"></i>
</div>
<div class="axis">
<div class="y-axis"><span>Y</span></div>
<div class="x-axis"><span>X</span></div>
<div class="z-axis"><span>Z</span></div>
</div>
In most cases the order matters look at this. First translate (it also changes the rotation center or axis) then scale then rotate.
function reRun() {
document.querySelector('.item').classList.remove('spin-animation')
setTimeout(function() {
document.querySelector('.item').classList.add('spin-animation')
},300)
}
#keyframes spin {
0% {
transform: translate(0, 0) scale(1) rotateY(0deg);
}
25% {
transform: translate(-1rem, -1rem) scale(2) rotateY(360deg);
}
50% {
transform: translate(-1.5rem, -1.5rem) scale(3) rotateY(0deg);
}
75% {
transform: translate(-2rem, -2rem) scale(4) rotateY(360deg);
}
100% {
transform: translate(-2.5rem, -2.5rem) scale(5) rotateY(0deg);
}
}
.spin-animation {
animation: spin 2s linear forwards;
}
.item {
position: absolute;
bottom: 1rem;
right: 1rem;
font-size: 2rem;
color: red;
}
.axis {
position: absolute;
right: 0.8rem;
bottom: 1.2rem;
}
.y-axis {
width: 1px;
height: 300px;
background: black;
position: absolute;
right: 0;
bottom: 0;
}
.x-axis {
width: 300px;
height: 1px;
background: black;
}
.z-axis {
width: 1px;
height: 300px;
position: absolute;
right: 0;
bottom: 0;
background: black;
transform: skewX(45deg);
transform-origin: right bottom;
}
.z-axis span {
padding: 0.5rem;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<button onclick="reRun()">ReRun the Example</button>
<div class="item spin-animation">
<i class="fa fa-question" aria-hidden="true"></i>
</div>
<div class="axis">
<div class="y-axis"><span>Y</span></div>
<div class="x-axis"><span>X</span></div>
<div class="z-axis"><span>Z</span></div>
</div>

How to disable v-tooltip when user click outside

I use v-tooltip to show tooltip on every cell of table
<td v-tooltip="{content: 'some content', trigger: 'click'}"></td>
But I want when user click another cell, current tooltip will disapear, I have tried "autoHide" property, but it not working.
Thanks
v-tooltip repository:
https://github.com/Akryum/v-tooltip
It's a late answer but maybe it can help someone else:
you can add the tooltip component as a ref and call the hide method:
this.$refs.popover.hide()
I think you will have to use the more customizable v-popover component. The v-tooltip directive doesn't seem to handle manual triggering, and you need manual triggering.
console.clear();
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
selectedCell: null
}
})
body {
font-family: sans-serif;
margin: 42px;
}
.tooltip {
display: block !important;
z-index: 10000;
}
.tooltip .tooltip-inner {
background: black;
color: white;
border-radius: 16px;
padding: 5px 10px 4px;
}
.tooltip .tooltip-arrow {
width: 0;
height: 0;
border-style: solid;
position: absolute;
margin: 5px;
border-color: black;
}
.tooltip[x-placement^="top"] {
margin-bottom: 5px;
}
.tooltip[x-placement^="top"] .tooltip-arrow {
border-width: 5px 5px 0 5px;
border-left-color: transparent !important;
border-right-color: transparent !important;
border-bottom-color: transparent !important;
bottom: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
.tooltip[x-placement^="bottom"] {
margin-top: 5px;
}
.tooltip[x-placement^="bottom"] .tooltip-arrow {
border-width: 0 5px 5px 5px;
border-left-color: transparent !important;
border-right-color: transparent !important;
border-top-color: transparent !important;
top: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
.tooltip[x-placement^="right"] {
margin-left: 5px;
}
.tooltip[x-placement^="right"] .tooltip-arrow {
border-width: 5px 5px 5px 0;
border-left-color: transparent !important;
border-top-color: transparent !important;
border-bottom-color: transparent !important;
left: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
.tooltip[x-placement^="left"] {
margin-right: 5px;
}
.tooltip[x-placement^="left"] .tooltip-arrow {
border-width: 5px 0 5px 5px;
border-top-color: transparent !important;
border-right-color: transparent !important;
border-bottom-color: transparent !important;
right: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
.tooltip[aria-hidden='true'] {
visibility: hidden;
opacity: 0;
transition: opacity .15s, visibility .15s;
}
.tooltip[aria-hidden='false'] {
visibility: visible;
opacity: 1;
transition: opacity .15s;
}
<script src="//unpkg.com/popper.js"></script>
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/v-tooltip"></script>
<div id="app">
<table border="1">
<tr v-for="i in 3">
<td #click="selectedCell = i">
<p><span>This is cell {{ i }}</span></p>
<v-popover trigger="manual" :open="selectedCell === i">
<template slot="popover">
<p>
{{ message }}
</p>
</template>
</v-popover>
</td>
</tr>
</table>
</div>

Bootstrap Lighbox - how to add caption with link?

I would like some of my Lightbox gallery images to have a caption with a link to another website. And if the caption link can open up in a new window/tab like the target="_blank" style. But I have no idea how to do this. Could I have some help please? Thanks in advance :)
Code for one gallery image:
<li class="col-xs-6 col-sm-6 col-md-3 col-lg-3 bottom-space">
<a href="img/photos/gallery/gallery_photo044.jpg" data-lightbox="tristone" data-title="My caption goes here">
<img class="img-responsive" src="img/photos/gallery-thumbs/gallery-thumbs044.jpg">
</a>
</li>
I have read somewhere I could use data attributes, so I tried data-href:
<li class="col-xs-6 col-sm-6 col-md-3 col-lg-3 bottom-space">
<a href="img/photos/gallery/gallery_photo044.jpg" data-lightbox="tristone" data-title="My caption goes here" data-href="http://mylinkgoeshere">
<img class="img-responsive" src="img/photos/gallery-thumbs/gallery-thumbs044.jpg">
</a>
</li>
But of course that didn't work since I don't really know what data-href does so I was just guessing :( I did look up about it but I guess my coding level isn't good enough so I don't understand it ^^;
Lightbox.css:
/* Preload images */
body:after {
content: url(../img/close.png) url(../img/loading.gif) url(../img/prev.png) url(../img/next.png);
display: none;
}
.lightboxOverlay {
position: absolute;
top: 0;
left: 0;
z-index: 9999;
background-color: black;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
opacity: 0.8;
display: none;
}
.lightbox {
position: absolute;
left: 0;
width: 100%;
z-index: 10000;
text-align: center;
line-height: 0;
font-weight: normal;
}
.lightbox .lb-image {
display: block;
height: auto;
max-width: inherit;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
-o-border-radius: 3px;
border-radius: 3px;
}
.lightbox a img {
border: none;
}
.lb-outerContainer {
position: relative;
background-color: white;
*zoom: 1;
width: 250px;
height: 250px;
margin: 0 auto;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
-o-border-radius: 4px;
border-radius: 4px;
}
.lb-outerContainer:after {
content: "";
display: table;
clear: both;
}
.lb-container {
padding: 4px;
}
.lb-loader {
position: absolute;
top: 43%;
left: 0;
height: 25%;
width: 100%;
text-align: center;
line-height: 0;
}
.lb-cancel {
display: block;
width: 32px;
height: 32px;
margin: 0 auto;
background: url(../img/loading.gif) no-repeat;
}
.lb-nav {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
}
.lb-container > .nav {
left: 0;
}
.lb-nav a {
outline: none;
background-image: url('data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
}
.lb-prev, .lb-next {
height: 100%;
cursor: pointer;
display: block;
}
.lb-nav a.lb-prev {
width: 34%;
left: 0;
float: left;
background: url(../img/prev.png) left 48% no-repeat;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
-webkit-transition: opacity 0.6s;
-moz-transition: opacity 0.6s;
-o-transition: opacity 0.6s;
transition: opacity 0.6s;
}
.lb-nav a.lb-prev:hover {
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
.lb-nav a.lb-next {
width: 64%;
right: 0;
float: right;
background: url(../img/next.png) right 48% no-repeat;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
-webkit-transition: opacity 0.6s;
-moz-transition: opacity 0.6s;
-o-transition: opacity 0.6s;
transition: opacity 0.6s;
}
.lb-nav a.lb-next:hover {
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
.lb-dataContainer {
margin: 0 auto;
padding-top: 5px;
*zoom: 1;
width: 100%;
-moz-border-radius-bottomleft: 4px;
-webkit-border-bottom-left-radius: 4px;
border-bottom-left-radius: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.lb-dataContainer:after {
content: "";
display: table;
clear: both;
}
.lb-data {
padding: 0 4px;
color: #ccc;
}
.lb-data .lb-details {
width: 85%;
float: left;
text-align: left;
line-height: 1.1em;
}
.lb-data .lb-caption {
font-size: 13px;
font-weight: bold;
line-height: 1em;
}
.lb-data .lb-number {
display: block;
clear: left;
padding-bottom: 1em;
font-size: 12px;
color: #999999;
}
.lb-data .lb-close {
display: block;
float: right;
width: 30px;
height: 30px;
background: url(../img/close.png) top right no-repeat;
text-align: right;
outline: none;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=70);
opacity: 0.7;
-webkit-transition: opacity 0.2s;
-moz-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
transition: opacity 0.2s;
}
.lb-data .lb-close:hover {
cursor: pointer;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}