Bootstrap 4 Alpha 6 Vertical Carousel - css

I'm trying to create a vertically oriented carousel in Bootstrap 4 Alpha 6. I still can't figure out for the life of me why the folks at Bootstrap don't include this orientation but I've come close to a solution of my own. I seem to be missing something in my CSS but cant seem to place it.
Check out my demo here on JSFIDDLE
My problem is the non upward fluid movement of the carousel slides. The slides come up from the bottom but don't continue up when they're ending -- dissappear rather.
I'm building this code from compiling old methods of doing this with BS3 and trying to match up the new CSS classes the best I can. Here's my code, any help in solving this mystery would be much appreciated.
HTML
<!-- Bootstrap Carousel -->
<div id="testCarousel" class="carousel slide vertical" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#testCarousel" data-slide-to="0" class="active"></li>
<li data-target="#testCarousel" data-slide-to="1"></li>
<li data-target="#testCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block img-fluid" src="//placehold.it/2500x750" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="//placehold.it/2500x750" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="//placehold.it/2500x750" alt="Third slide">
</div>
</div>
</div>
CSS
/* Just for Example Purposes */
body {
background: #333
}
/* Vertical Carousel */
.vertical .carousel-inner {
height: 100%;
}
.carousel.vertical .carousel-item {
-webkit-transition: 0.6s ease-in-out top;
-moz-transition: 0.6s ease-in-out top;
-ms-transition: 0.6s ease-in-out top;
-o-transition: 0.6s ease-in-out top;
transition: 0.6s ease-in-out top;
}
.carousel.vertical .active {
top: 0;
}
.carousel.vertical .carousel-item-next {
top: 100%;
}
.carousel.vertical .carousel-item-prev {
top: -100%;
}
.carousel.vertical .carousel-item-next.carousel-item-left,
.carousel.vertical .carousel-item-prev.carousel-item-right {
top: 0;
}
.carousel.vertical .active.carousel-item-left {
top: -100%;
}
.carousel.vertical .active.carousel-item-right {
top: 100%;
}
.carousel.vertical .carousel-item {
left: 0;
}
So, rather than the carousel slides blinking out or just disappearing, then reappearing, I would like them to flow naturally upward as if the hidden images weren't left aligned as they are by default in Bootstrap.
Thanks in advance!!!

Updated 2018 for Bootstrap 4.0.0
The Bootstrap 4 animation transitions use transform, so I think it would be better to use translate to change the orientation to vertical, and the position of each slide...
Demo: http://www.codeply.com/go/PgxKT3h6x6
.vert .carousel-item-next.carousel-item-left,
.vert .carousel-item-prev.carousel-item-right {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.vert .carousel-item-next,
.vert .active.carousel-item-right {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100% 0);
}
.vert .carousel-item-prev,
.vert .active.carousel-item-left {
-webkit-transform: translate3d(0,-100%, 0);
transform: translate3d(0,-100%, 0);
}
Vertical Carousel Demo

Related

Image scroll within div

I'm trying to achieve the following scrolling effect from the Rocket.Chat homepage.
See effect here
Site: https://rocket.chat/
The issue is that I can't seem to make the image move like they have in the site. Does somebody have any idea why? Or can pass an example?
My component.html
<section class="community py-5">
<div class="container">
<div class="content d-flex">
<div class="content-info">
<div class="mb-5">
<h3>Lorem ipsum text</h3>
</div>
<div class="text-wrapper">
<div class="text">
Some information to be said
</div>
</div>
<div class="btn-wrapper mt-5">
<a href="#" class="btn-contract-us">
<div>
<strong>Join Us</strong>
</div>
</a>
</div>
</div>
<div class="content-image">
<img
[src]="codeImg"
alt=""
draggable="false"
/>
</div>
</div>
</div>
</section>
My component.scss
.community {
position: relative;
.content-info {
padding: 110px 140px 64px;
flex: 1;
background-color: #f7f8fa;
// background-img
background-position: -40px 0;
background-size: 730px;
background-repeat: no-repeat;
div.text {
margin: 0;
font-size: 1.6rem;
line-height: 3.2rem;
}
.btn-contract-us {
background-color: #f5455c;
}
}
.content-image {
overflow: hidden;
width: 30%;
max-height: 524px;
max-width: 430px;
background-color: #1f2329;
background-image: linear-gradient(180deg, #1f2329 60%, #000);
img {
transform: translate3d(0px, -45.9095%, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg);;
transform-style: preserve-3d;
will-change: transform;
}
}
}
You can use a css-keyframe-animation of the background-image for that:
.component{
display: flex;
align-items: center;
justify-content: space-between;
}
.image{
width:300px;
height:200px;
background-image: url('https://placekitten.com/300/400');
animation: scrollImage;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: ease-in-out;
}
#keyframes scrollImage{
from{
background-position: center 0%
}
to{
background-position: center 100%
}
}
<div class="component">
<div class="content">
<h1>Look, Ma!</h1>
<p>I animated a kitten instead of sourcecode.</p>
</div>
<div class="image"></div>
</div>
Usage:
animation-duration - sets the duration of one iteration of your animation
animation-iteration-count: infinite - lets your animation run endlessly
animation-direction: alternate - lets your animation loop back and forth over and over again

Why is the animation rot-corona not working?

I am working on a coronavirus project and the animation rot-corona is not working I want it to rotate 360 degrees after every 3 sec
and for a note bootstrap-4 is included in it
Code
/* SCSS */
#rotate-corona-text {
h1 {
font-size: 3rem;
}
img {
width: 100px;
height: 100px;
}
#rotate-corona-text {
img {
animation: rot-corona 3s linear infinite;
}
}
}
<section id="main-header" class="py-4">
<div class="container py-4">
<div class="row border py-4 align-items-center justify-content-between">
<div class="col-12 col-md-4 order-2 order-lg-1 " id="unity-images">
</div>
<div class="col-12 col-md-7 order-1 order-lg-2" id="rotate-corona-text">
<h1 class="text-primary">lets stay safe and fight against cor<span id="rotate-cororna"><img src="./assets/corona-icon.jpg" alt=""></span>na </h1>
</div>
</div>
</div>
</section>
and for the image which I want to rotate is https://ibb.co/qFSqkyq
SCSS compiles to this:
#rotate-corona-text h1 {
font-size: 3rem;
}
#rotate-corona-text img {
width: 100px;
height: 100px;
}
#rotate-corona-text #rotate-corona-text img {
animation: rot-corona 3s linear infinite;
}
Note that the 3rd statement has a multiple ID selector that does not select the node required.
You are missing #keyframes to define the animation that you have declared for the img.
Output:
#rotate-corona-text h1 {
font-size: 3rem;
}
#rotate-corona-text img {
width: 100px;
height: 100px;
}
#rotate-corona-text img {
animation: rot-corona 6s infinite; /* 6s because 50% is completed at 3s. */
}
#keyframes rot-corona {
0% {
transform: rotate(0);
}
50% {
transform: rotate(360deg); /* CSS does not offer animation-delay between iterations. This is a hack */
}
100% {
transform: rotate(360deg);
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<section id="main-header" class="py-4">
<div class="container py-4">
<div class="row border py-4 align-items-center justify-content-between">
<div class="col-12 col-md-4 order-2 order-lg-1 " id="unity-images">
</div>
<div class="col-12 col-md-7 order-1 order-lg-2" id="rotate-corona-text">
<h1 class="text-primary">Lets stay safe and fight against Cor<span id="rotate-cororna"><!-- Transparent background for you --><img src="https://i.stack.imgur.com/9Wifk.png" alt=""></span>na </h1>
</div>
</div>
</div>
</section>

Apply CSS Moving Transition to element with `transform` property

I want to apply CSS move transition to element with transform property.
Before transition:
<ul class="list">
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
After transition:
<ul class="list">
<li>two</li>
<li>three</li>
<li>one</li>
</ul>
CSS:
.list > li {
transform: skewX(15deg);
transform-origin: bottom left;
}
I tried to apply transition: transform 1s, then skewX was also reset and re-applied.
Example video here: https://youtu.be/n3qC3uny5uM
How can I apply transition to only movement, not shape transform?
You can do something like following using CSS Animation.
.container {
background: #f7f8f9;
display: flex;
}
.container div {
width: 40px;
height: 100px;
background: #fcc700;
margin: 0 4px;
animation: spin linear 1.2s;
// animation: spin linear 1s infinite;
}
#keyframes spin {
from {
transform: translateX(-50px);
}
to {
transform: translateX(50px) skewX(-15deg);
}
}
<div class="container">
<div>A</div>
<div>B</div>
</div>

Bootstrap 4 alpha5 carousel fade

Good Day, Trying to get carousel fade transition to work. Any help will be appreciated. Here is code that I have so far.
Boot version: 4, alpha 5
Boot includes between header tags:
<link rel="stylesheet" href="boot/css/bootstrap.min.css">
<link rel="stylesheet" href="boot/css/bootstrap-flex.min.css">
<link rel="stylesheet" href="boot/css/bootstrap-grid.min.css">
<link rel="stylesheet" href="boot/css/bootstrap-reboot.min.css">
Custom css between header and after above boot includes. I know (Important) is likely not necessary, but i am running out of options.
.carousel-fade .carousel-inner .item {
-webkit-transition-property: opacity !important;
transition-property: opacity !important;
}
.carousel-fade .carousel-inner .item,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
opacity: 0 !important;
}
.carousel-fade .carousel-inner .active,
.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
opacity: 1 !important;
}
.carousel-fade .carousel-inner .next,
.carousel-fade .carousel-inner .prev,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
left: 0 !important;
-webkit-transform: translate3d(0, 0, 0) !important;
transform: translate3d(0, 0, 0) !important;
}
Now this is my not working carusel.
<div id="carousel-example-generic" class="carousel carousel-fade" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img src="images/img1.png" alt="First slide">
</div>
<div class="carousel-item">
<img src="images/img2.png" alt="Second slide">
</div>
</div>
</div>
Now my boot includes before end of body tag:
<!-- Boot Includes -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" integrity="sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js" integrity="sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB" crossorigin="anonymous"></script>
<script src="boot/js/bootstrap.min.js"></script>
JS for slideshow
$('.carousel').carousel({
interval: 9000,
pause: false
})
If all fails, please recommend a simple java slider. I just want plain and simple image transition with fade effect. No need for any controls or sub titles.
See the below example.
$('.carousel').carousel({
interval: 3000,
pause: false
});
.carousel-fade .carousel-inner .carousel-item {
-webkit-transition-property: opacity;
-moz-transition-property: opacity;
-o-transition-property: opacity;
-ms-transition-property: opacity;
transition-property: opacity;
}
.carousel-fade .carousel-inner .carousel-item,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
opacity: 0;
}
.carousel-fade .carousel-inner .active,
.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
opacity: 1;
}
.carousel-fade .carousel-inner .next,
.carousel-fade .carousel-inner .prev,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
left: 0;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script>
<div class="carousel slide carousel-fade" id="carousel">
<div class="carousel-inner">
<div class="carousel-item active" style="width:100%;height:400px;background:red;"></div>
<div class="carousel-item" style="width:100%;height:400px;background:blue;"></div>
<div class="carousel-item" style="width:100%;height:400px;background:green;"></div>
<div class="carousel-item" style="width:100%;height:400px;background:yellow;"></div>
</div>
<a class="left carousel-control" href="#carousel" role="button" data-slide="prev">
<span class="icon-prev" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel" role="button" data-slide="next">
<span class="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
I just wasted hours of my life using Bootstrap 4.0.0-alpha.5 & adjusting some of the snippets above. The class names have changed & the display method on some elements is flexbox so the image would not resize perspective (responsive) to window width. Do yourself a favour & wait for the official release.
If you enjoy a challenge I can at least save you some time. This works (fading carousel slides) in Chrome. Have not tested other browsers.
.carousel-item.active,
.carousel-item-next,
.carousel-item-prev
{
/*SET IN BS AS FLEXBOX. SO PERSPECTIVE SCALE DID NOT WORK*/
display:block;
}
.carousel-inner>.carousel-item>a>img,
.carousel-inner>.carousel-item>img,
.img-responsive
{
display: block;
max-width: 100%;
height: auto;
}
.carousel-fade .carousel-inner .carousel-item {
-webkit-transition-property: opacity;
-moz-transition-property: opacity;
-o-transition-property: opacity;
-ms-transition-property: opacity;
transition-property: opacity;
}
.carousel-inner .carousel-item,
.carousel-inner .active.carousel-item-left,
.carousel-inner .active.carousel-item-right
{
opacity:0;
}
.carousel-inner .active,
.carousel-inner .carousel-item-next.carousel-item-left,
.carousel-inner .carousel-item-previous.carousel-item-right
{
opacity: 1;
}
.carousel-item.active,
.active.carousel-item-left,
.active.carousel-item-prev,
.carousel-item-next.carousel-item-left,
.carousel-item-prev.carousel-item-right
{
left: 0;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
I also grabbed the classes from the BS JS file:
var ClassName = {
CAROUSEL: 'carousel',
ACTIVE: 'active',
SLIDE: 'slide',
RIGHT: 'carousel-item-right',
LEFT: 'carousel-item-left',
NEXT: 'carousel-item-next',
PREV: 'carousel-item-prev',
ITEM: 'carousel-item'
};
UPDATE EDIT 4.0.0-beta.2 5th December 2017:
.carousel-item {
opacity: 0;
transition: opacity 0.6s ease !important;
}
.carousel-item-next,
.carousel-item-prev {
left: 0 !important;
}
.carousel-item-next.carousel-item-left,
.carousel-item-prev.carousel-item-right {
-webkit-transform: none;
transform: none;
}
#supports ((-webkit-transform-style: preserve-3d) or (transform-style: preserve-3d)) {
.carousel-item-next.carousel-item-left,
.carousel-item-prev.carousel-item-right {
-webkit-transform: none;
transform: none;
}
}
.carousel-item-next,
.active.carousel-item-right {
-webkit-transform: none;
transform: none;
}
#supports ((-webkit-transform-style: preserve-3d) or (transform-style: preserve-3d)) {
.carousel-item-next,
.active.carousel-item-right {
-webkit-transform: none;
transform: none;
}
}
.carousel-item-prev,
.active.carousel-item-left {
-webkit-transform: none;
transform: none;
}
#supports ((-webkit-transform-style: preserve-3d) or (transform-style: preserve-3d)) {
.carousel-item-prev,
.active.carousel-item-left {
-webkit-transform: none;
transform: none;
}
}
// THE FIX
.carousel-inner .carousel-item,
.carousel-inner .active.carousel-item-left,
.carousel-inner .active.carousel-item-right
{
opacity:0;
}
.carousel-inner .active,
.carousel-inner .carousel-item-next.carousel-item-left,
.carousel-inner .carousel-item-prev.carousel-item-right
{
opacity: 1;
}
You may be able to trim some of the fat out this further? Working in FF, Chrome & Safari (IE/Edge untested).
Try this, its work on my bootstrap 4 beta carousel
.carousel-fade .carousel-item {
opacity: 0;
-webkit-transition-duration: .6s;
transition-duration: .6s;
-webkit-transition-property: opacity;
transition-property: opacity;
}
.carousel-fade .carousel-item.active,
.carousel-fade .carousel-item-next.carousel-item-left,
.carousel-fade .carousel-item-prev.carousel-item-right {
opacity: 1;
}
.carousel-fade .active.carousel-item-left,
.carousel-fade .active.carousel-item-right {
opacity: 0;
}
.carousel-fade .carousel-item-next,
.carousel-fade .carousel-item-prev,
.carousel-fade .carousel-item.active,
.carousel-fade .active.carousel-item-left,
.carousel-fade .active.carousel-item-prev {
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
#supports (transform-style: preserve-3d) {
.carousel-fade .carousel-item-next,
.carousel-fade .carousel-item-prev,
.carousel-fade .carousel-item.active,
.carousel-fade .active.carousel-item-left,
.carousel-fade .active.carousel-item-prev {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<div id="carouselExampleIndicators" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://c1.staticflickr.com/7/6107/6381966401_032df5fe1e_b.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="http://saxony-blue.com/data/out/86/5918348-image.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://www.gettyimages.ca/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
Try this, it's working in my test build:
.carousel-fade .carousel-item {
position: absolute;
display: block;
transition: opacity .9s ease-in-out;
opacity: 0;
}
.carousel-fade .carousel-item.active {
opacity: 1;
}
I also find that .carousel-fade {background-color: #000000;} makes the transition look smoother if your items have background images.
In v4-alpha, the carousel system was largely rewritten, so the class and transition targeting in previous answers only works with Bootstrap 3. Here's a snippet from the v4.0.0-alpha.6 build that demonstrates how the Bootstrap team rewrote classes:
// CSS3 transforms when supported by the browser
#include if-supports-3d-transforms() {
.carousel-item-next.carousel-item-left,
.carousel-item-prev.carousel-item-right {
transform: translate3d(0, 0, 0);
}
I've come up with a rather easy solution for Bootstrap 4.0.0-beta:
Stack carousel items using position: absolute
Display carousel items, set opacity to 0
Set opacity to 1 on the active carousel item
.carousel-fade .carousel-item {
display: block;
position: absolute;
top: 0;
left: 0;
right: 0;
opacity: 0;
transition: opacity 500ms ease;
}
.carousel-fade .carousel-item.active {
opacity: 1;
}
/* Fixed height, can be dynamic using JS */
.carousel-fade .carousel-inner,
.carousel-fade .carousel-item {
height: 300px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<div class="carousel carousel-fade" data-ride="carousel" data-interval="2000">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active" style="background: red">
<div class="container">
<h1>Item 1</h1>
</div>
</div>
<div class="carousel-item" style="background: blue">
<div class="container">
<h1>Item 2</h1>
</div>
</div>
<div class="carousel-item" style="background: green">
<div class="container">
<h1>Item 3</h1>
</div>
</div>
</div>
</div>
<!-- jQuery !-->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
crossorigin="anonymous"></script>
<!-- Popper !-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<!-- Bootstrap !-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"
integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
The carousel wrapper element does not inherit the height of its children since the carousel items are absolute positioned. This mean we have to set a fixed height for a pure-CSS solution, though we can easily solve this with some JavaScript:
// Set min-height property based on the tallest carousel item.
(function () {
var $inner = $('.carousel-inner'),
$items = $('.carousel-item');
var maxHeight = Math.max.apply(null,
$items.map(function() {
return $(this).outerHeight();
})
);
$inner
.add($items)
.css('min-height', maxHeight);
})();
Happy coding.
HTML:
<div id="carousel-example-generic" class="carousel carousel-fade" data-ride="carousel">
----
---
</div>
CSS:
.carousel-fade .carousel-inner .item {
-webkit-transition-property: opacity;
transition-property: opacity;
}
.carousel-fade .carousel-inner .item,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
opacity: 0;
}
.carousel-fade .carousel-inner .active,
.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
opacity: 1;
}
.carousel-fade .carousel-inner .next,
.carousel-fade .carousel-inner .prev,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
left: 0;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
JS:
$('.carousel').carousel({
interval: 9000,
pause: false
})

CSS - stopping animation with :hover (no JS)

Is there any way of stopping animation with :hover and make it run again once hovered off?
This part is solved:
I thought of doing it with animation-state-paused, but as the animation runs on multiple elements with precised animation-delay, such solution desynchronizes elements.
What I would like to achieve 'at least' is to stop all of the animation once hovered.
Still looking for solution for this part:
And the Great Achievement would be (additionaly) to change z-index so the hovered picture goes in front of all the other ones... and come backs to its z-index from animation once hovered off + animation continues the cycle.
Important thing - NO JAVASCRIPT (I'd really like to use it, but I cannot because of some CMS settings).
Code without hover: CODEPEN and SOSnippet:
.cube2>div{
position:absolute;
left:50%;
transform: translateX(-50%);
width:450px;
}
.playground2 {
overflow: hidden;
}
.frame {
position: absolute;
top:-12px;
left:-1px;
z-index: 1;}
.one, .two, .three, .four, .five, .six, .seven, .eight{
animation: comedown 32s infinite ease-in-out
}
.eight {
animation-delay: 0s
}
.seven {
animation-delay: 4s
}
.six {
animation-delay: 8s
}
.five {
animation-delay: 12s
}
.four {
animation-delay: 16s
}
.three {
animation-delay: 20s
}
.two {
animation-delay: 24s
}
.one {
animation-delay: 28s;
}
.container {
background: darkkhaki;
height: 400px;
position: relative;
}
.cube2 {
top: 100px;
height: 300px;
position: relative;
left: 50%;
transform: translateX(-50%);
}
#-webkit-keyframes comedown {
0% {
top: 0%;
z-index: 1;
}
12.5% {
top: 120%;
z-index: 2;
left:50%;
transform:translateX(-50%);
}
13%{z-index:-15}
25%{
top:-50px;
transform: translateX(-32%)
}
35%{z-index:-10}
37.5%{
top:-42px;
transform: translateX(-35%);
}
50%{
top:-36px;
transform: translateX(-38%);
z-index:-6;
}
62.5%{
top:-28px;
transform: translateX(-41%);
z-index:-5;
}
75%{
top:-20px;
transform: translateX(-44%);
z-index:-4;
}
87.5%{
top:-12px;
transform: translateX(-47%);
z-index:-3;
}
100%{
top:0px;
left:50%;
transform:translateX(-50%);
z-index:-2;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="playground2 container">
<div class="cube2">
<div class="one">
<img class="face" src="https://s17.postimg.org/71iegzebj/img_little.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="two">
<img class="face" src="https://s17.postimg.org/duncqzuin/img_little3.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="three">
<img class="face" src="https://s17.postimg.org/o3b8j2t6n/img_little2.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="four">
<img class="face" src="https://s17.postimg.org/v97kz9rnj/img_little4.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="five">
<img class="face" src="https://s16.postimg.org/4reke4owl/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="six">
<img class="face" src="https://s16.postimg.org/3qebp07x1/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="seven">
<img class="face" src="https://s16.postimg.org/fgs96e0ph/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="eight">
<img class="face" src="https://s16.postimg.org/xxmnx7gnp/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
</div>
</div>
The trick is to catch :hover on .cube2.
This will pause the animation:
.cube2:hover > div{
-webkit-animation-play-state: paused; /* Safari 4.0 - 8.0 */
animation-play-state: paused;
}
To bring image box to front using z-index, use this:
.cube2 > div:hover{
z-index: 99 !important;
}
.cube2:hover > div.one, .cube2:hover >.two, .cube2:hover >.three, .cube2:hover >.four, .cube2:hover >.five,.cube2:hover > .six, .cube2:hover >.seven, .cube2:hover >.eight{
animation-play-state: paused;
}
This way all animation is stopped since you call hover on .cube2
See:
https://jsfiddle.net/duuhr712/

Resources