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>
Related
I've got the following code which rotates words with a CSS animation. I'm trying to figure out how to pause the animation on each word, before moving to the next word. I've tried using animation-delay, but that only applies to the start of the animation rather than each item.
How can I pause the animation FOR EACH WORD?
.im {
float: left;
margin-right: 0.3em;
}
.im-wrapper {
display: flex;
height: 1.1em;
}
.im-items {
overflow: hidden;
}
.im-item {
display: block;
height: 100%;
color: $primary;
animation: move 10s infinite;
animation-delay: 1s;
white-space: nowrap;
}
#keyframes move {
0% {
transform: translateY(0%);
}
20% {
transform: translateY(-100%);
}
40% {
transform: translateY(-200%);
}
60% {
transform: translateY(-300%);
}
80% {
transform: translateY(-400%);
}
100% {
transform: translateY(0%);
}
}
<div class="hero-top-title">
<div style="display: inline-block;">
<div>Hi</div>
</div>, I'm
<div style="display: inline-block;">
<div>A Person</div>
</div>.
<br>
<div class="im">Am I a</div>
<div class="im-wrapper">
<div class="im-items">
<div class="im-item im-item1">Father</div>
<div class="im-item im-item2">Mother</div>
<div class="im-item im-item3">Brother</div>
<div class="im-item im-item4">Sister</div>
<div class="im-item im-item5">Grandma</div>
</div>
<div>?</div>
</div>
</div>
How can I pause the animation FOR EACH WORD?
Need to keep the same transform of couple of moment then trigger next. Please follow the code below and you will understand what I mean.
.im {
float: left;
margin-right: 0.3em;
}
.im-wrapper {
display: flex;
height: 1.1em;
}
.im-items {
overflow: hidden;
}
.im-item {
display: block;
height: 100%;
color: $primary;
animation: move 10s infinite;
animation-delay: 1s;
white-space: nowrap;
}
/* Here is the different */
#keyframes move {
0% {
transform: translateY(0%);
}
10% {
transform: translateY(-100%);
}
20% {
transform: translateY(-100%);
}
30% {
transform: translateY(-200%);
}
40% {
transform: translateY(-200%);
}
50% {
transform: translateY(-300%);
}
60% {
transform: translateY(-300%);
}
70% {
transform: translateY(-400%);
}
80% {
transform: translateY(-400%);
}
90% {
transform: translateY(0%);
}
100% {
transform: translateY(0%);
}
}
<div class="hero-top-title">
<div style="display: inline-block;">
<div>Hi</div>
</div>, I'm
<div style="display: inline-block;">
<div>A Person</div>
</div>.
<br>
<div class="im">Am I a</div>
<div class="im-wrapper">
<div class="im-items">
<div class="im-item im-item1">Father</div>
<div class="im-item im-item2">Mother</div>
<div class="im-item im-item3">Brother</div>
<div class="im-item im-item4">Sister</div>
<div class="im-item im-item5">Grandma</div>
</div>
<div>?</div>
</div>
</div>
Delay works only once at the start. So doesn't work with multiple iterations. You need to add blank frames like Feroz suggestd.
Here is a thread about the same topic: CSS animation delay in repeating
What you are trying is some sort of vertical carousel. Look for CSS only carousels. Following is an example, you can repurpose it to slide your text. You need to adjust animation slideMe to change pause time. Click on 'Full page' to see it better.
A codepen demo:
<iframe height="400px" style="width: 100%;" scrolling="no" title="CSS only - A scalable auto sliding carousel -vertical" src="https://codepen.io/onkarruikar/embed/RwZzrMp?default-tab=result&theme-id=dark" frameborder="no" loading="lazy" allowtransparency="true"
allowfullscreen="true">
See the Pen <a href="https://codepen.io/onkarruikar/pen/RwZzrMp">
CSS only - A scalable auto sliding carousel -vertical</a> by OnkarRuikar (#onkarruikar)
on CodePen.
</iframe>
I add an animation when it become "display:block;" :
.button:hover > .list {
display: block;
}
.list {
display: none;
animation: listshow 0.8s ease normal;
}
#keyframes listshow {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<div class="button">
<div>Show</div>
<ul class="list">
<li>1</li>
<li>2</li>
</ul>
</div>
But how can I add an animation when it become "display:none;" ?
Thanks for your time.
Rather than using a keyframe, you can set the element to opacity:0 and then on your :hover set opacity:1 and then add a transition to your your list class (since you are just playing with Opacity):
.button:hover > .list {
display: block;
opacity: 1;
}
.list{
opacity: 0;
transition: 0.8s ease-in-out;
}
<div class="button">
<div>Show</div>
<ul class="list">
<li>1</li>
<li>2</li>
</ul>
</div>
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
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/
Trying to make CSS functional map:
CSS
.fader-us {
display: none;
}
.fader-us-content {
display: none;
position: fixed;
top:50px;
left:50px;
z-index:81;
}
.fader-us:active .fader-us-content {
display:block;
}
.fader-us:active .us {
opacity:0;
}
.fader-us-content:hover {
display: block;
}
.fader-us-content:hover .us {
opacity:0;
}
.fader-us img {
line-height: 0;
z-index:79;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.us {
position:fixed;
top:33px;
left:55px;
z-index:0;
}
HTML
<div class="fader-us">
<img class ="us" src="us.png" alt="">
<div class="fader-us-content">
<li>California</li>
<li>Florida</li>
</div>
</div>
What im trying to do is make us.png img to disappear when my mouse is over "fader-us-content".
Can't figure out why is the image disappearing only when I keep clicking.
Fiddle
http://jsfiddle.net/r9qHa/
Using '~' may be a good way:
.fader-us-content:hover~.us {
opacity:0;
}
Change the html like this:
<div class="fader-us">
<div class="text">
<p>USAs</p>
</div>
<ul class="fader-us-content">
<li>California</li>
<li>Florida</li>
</ul>
<img class ="us" src="http://s23.postimg.org/rixm8ire3/image.png" alt=""/>
</div>
jsfiddle.net
Try changing this:
<div class="fader-us">
<img class ="us" src="us.png" alt="">
<div class="fader-us-content">
<li>California</li>
<li>Florida</li>
</div>
</div>
.fader-us:active .fader-us-content {
display:block;
}
To This:
<div class="fader-us">
<img class ="us" src="us.png" alt="">
<div class="fader-us-content">
<ul>
<li>California</li>
<li>Florida</li>
</ul>
</div>
</div>
.fader-us:active .fader-us-content:hover {
display:block;
}
Working FIDDLE Demo
Add this rules at tne end of your styles:
.fader-us:hover .fader-us-content {
display:block;
}
.fader-us:hover .us { opacity: 0; }