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
})
Related
I made a project with just the important code: git
You can see it on the navbar buttons here(live website of the git project).
This css also changes the color of the moved text on some browsers (friends chrome, but not on mine). Have no clue how to fix it.
.underline {
position: relative;
text-decoration: none;
transition: all 0.35s ease;
}
.underline::before {
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 30%;
left: 0;
background-color: white;
visibility: hidden;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.underline:hover::before {
visibility: visible;
-webkit-transform: scaleX(0.9);
transform: scaleX(0.9);
}
nav {
height: 100px;
}
.navbar-item {
font-size: 25pt;
}
<nav className="navbar">
<div className="navbar-brand">
<Link href="/">
<a className="navbar-item">
<img src="/trinity-logo.png" />
</a>
</Link>
</div>
<div className="navbar-menu">
<div className="navbar-start">
<Link href="/">
<a className="navbar-item underline">
<b>Hover</b>
</a>
</Link>
<Link href="/">
<a className="navbar-item underline">
<b>Hover</b>
</a>
</Link>
<Link href="/">
<a className="navbar-item underline">
<b>Hover</b>
</a>
</Link>
</div>
</div>
</nav>
those navbar classes are from Bulma(I can't paste all of that css here).
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
I have list of different services provided, each service has an image, heading, and description. I've set it up so that image scales to 1.3x size on mouse hover. The scaling works, but it ignores the parent's borders when doing so.
I've captured a GIF of what it looks like in action.
Here is the code I'm working with.
.cleaningservices {
max-width: 250px;
max-height: 250px;
}
/* Default state of the image */
.hover01 img {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
/* Scale the image to 1.3 it's size on mouse hover */
.hover01:hover img {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/css/bootstrap-select.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<div class="cleaningservices">
<div class="col-sm-6 col-md-4">
<div class="thumbnail hover01">
<img src="https://bosworthco.com/wp-content/uploads/2016/10/cleaning-268134_960_720.jpg" alt="deep house cleaning">
<div class="caption">
<h3>Deep Cleaning</h3>
<p>Usually, on our first visit we will most likely have to complete a deep cleaning. It is a far more intensive cleaning that our regular cleaning. After first deep cleaning we will continue with one of our regularly scheduled cleanings below.</p>
</div>
</div>
</div>
</div>
</div>
What changes do I have to make to make the images scale inside the parent's borders on mouse hover?
you could add the image to a div and give the div overflow:hidden;
.hover01 img {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
width:100%;
}
.hover01:hover img {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
.img-parent{
overflow:hidden;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/css/bootstrap-select.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<div class="cleaningservices">
<div class="col-sm-6 col-md-4">
<div class="thumbnail hover01">
<div class="img-parent">
<img src="http://fiusms.fiu.edu/wp-content/uploads/Residential-Cleaning-Watauga-TX.jpg" alt="deep house cleaning">
</div>
<div class="caption">
<h3>Deep Cleaning</h3>
<p>Usually, on our first visit we will most likely have to complete a deep cleaning. It is a far more intensive cleaning that our regular cleaning. After first deep cleaning we will continue with one of our regularly scheduled cleanings below.</p>
</div>
</div>
</div>
</div>
</div>
just use overflow: hidden;
.hover01 img {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
overflow: hidden;
}
Create an img container on which you set overflow: hidden;. I added a background-color on body so you see it works.
body {
background-color: #f0f0f0 !important;
padding: 50px;
}
.noverflow {
overflow: hidden;
}
.thumbnail {
background-color: #fff;
}
.hover01 img {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.hover01:hover img {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/css/bootstrap-select.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<div class="cleaningservices">
<div class="col-sm-6 col-md-4">
<div class="thumbnail hover01">
<div class="noverflow"><img src="http://fiusms.fiu.edu/wp-content/uploads/Residential-Cleaning-Watauga-TX.jpg" alt="deep house cleaning"></div>
<div class="caption">
<h3>Deep Cleaning</h3>
<p>Usually, on our first visit we will most likely have to complete a deep cleaning. It is a far more intensive cleaning that our regular cleaning. After first deep cleaning we will continue with one of our regularly scheduled cleanings below.</p>
</div>
</div>
</div>
</div>
</div>
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/
I am having an issue identifying why after a CSS transition is applied on an icon/link it redraws in the wrong place.
Here is demo of it happening: https://jsfiddle.net/9n4edjzc/
div.rotate > a {
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
overflow: hidden;
}
div.rotate > a:hover {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />
<p>Why do the icons/links redraw in the wrong place after hover?</p>
<div class="rotate"> <i class="fa fa-github-square fa-2x"></i> <i class="fa fa-linkedin-square fa-2x"></i>
<i class="fa fa-rss-square fa-2x"></i>
</div>
Your links need to be block elements to begin with if they have images.
then you need containers so set them out properly.
the main requirement though is having your links as block elements.
Fixed
ul li {
display: inline-block;
list-style: none;
}
ul.rotate a {
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
display:block;
}
ul.rotate a:hover {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />
<p>Why do the icons/links redraw in the wrong place after hover?</p>
<ul class="rotate">
<li>
<i class="fa fa-github-square fa-2x"></i>
</li>
<li>
<i class="fa fa-linkedin-square fa-2x"></i>
</li>
<li>
<i class="fa fa-rss-square fa-2x"></i>
</li>
</ul>
Try to add display: inline-block; to div.rotate > a
SNIPPET
div.rotate > a {
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
overflow: hidden;
display: inline-block;
}
div.rotate > a:hover {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />
<p>Why do the icons/links redraw in the wrong place after hover?</p>
<div class="rotate"> <i class="fa fa-github-square fa-2x"></i> <i class="fa fa-linkedin-square fa-2x"></i>
<i class="fa fa-rss-square fa-2x"></i>
</div>
You need to make the anchor inline-block like this:
div.rotate > a {
display: inline-block;
transition: transform 0.8s;
overflow: hidden;
}
div.rotate > a:hover {
-webkit-transform:rotate(360deg);
transform:rotate(360deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />
<p>Why do the icons/links redraw in the wrong place after hover?</p>
<div class="rotate">
<i class="fa fa-github-square fa-2x"></i>
<i class="fa fa-linkedin-square fa-2x"></i>
<i class="fa fa-rss-square fa-2x"></i>
</div>
This works in all current browsers and is standard compliant, unlike the other answers that only work in some of them. It is also a lot cleaner as well.
This is probably a better way, if you don't mind changing the HTML:
ul li {
display: inline-block;
list-style: none;
}
a.rotate {
display: block;
transition: transform 0.8s;
overflow: hidden;
}
a.rotate:hover {
-webkit-transform:rotate(360deg);
transform:rotate(360deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />
<p>Why do the icons/links redraw in the wrong place after hover?</p>
<ul>
<li>
<i class="fa fa-github-square fa-2x"></i>
</li>
<li>
<i class="fa fa-linkedin-square fa-2x"></i>
</li>
<li>
<i class="fa fa-rss-square fa-2x"></i>
</li>
</ul>