I need my slider to stay fixed at the top of my page with my content (text) to be below it, but for some reason my text and content is scrolling behind the slider and the text/content is fading in and out below is the HTML code
<style type="text/css">.cb-slideshow,
.cb-slideshow:after {
position: fixed;
width: 100%;
height: 85%;
top: 0px;
left: 0px;
z-index: 0;
}
.cb-slideshow:after {
content: '';
background: transparent url(../images/pattern.png) repeat top left;
}
.cb-slideshow li span {
width: 100%;
height: 85%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
background-size: center top;
background-position: 50% 50%;
background-repeat: none;
opacity: 0;
z-index: 0;
animation: imageAnimation 36s linear infinite 0s;
}
.cb-slideshow li div {
z-index: 1000;
position: absolute;
bottom: 30px;
left: 0px;
width: 100%;
text-align: center;
opacity: 0;
color: #fff;
animation: titleAnimation 36s linear infinite 0s;
}
.cb-slideshow li div h3 {
font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
font-size: 240px;
padding: 0;
line-height: 200px;
}
.cb-slideshow li:nth-child(1) span {
background-image: url(/ckfinder/userfiles/7699/images/1.jpg)
}
.cb-slideshow li:nth-child(2) span {
background-image: url(/ckfinder/userfiles/7699/images/4.jpg);
animation-delay: 6s;
}
.cb-slideshow li:nth-child(3) span {
background-image: url(/ckfinder/userfiles/7699/images/7.jpg);
animation-delay: 12s;
}
.cb-slideshow li:nth-child(4) span {
background-image: url(/ckfinder/userfiles/7699/images/12.jpg);
animation-delay: 18s;
}
.cb-slideshow li:nth-child(5) span {
background-image: url(/ckfinder/userfiles/7699/images/14.jpg);
animation-delay: 24s;
}
.cb-slideshow li:nth-child(6) span {
background-image: url(/ckfinder/userfiles/7699/images/26.jpg);
animation-delay: 30s;
}
.cb-slideshow li:nth-child(2) div {
animation-delay: 6s;
}
.cb-slideshow li:nth-child(3) div {
animation-delay: 12s;
}
.cb-slideshow li:nth-child(4) div {
animation-delay: 18s;
}
.cb-slideshow li:nth-child(5) div {
animation-delay: 24s;
}
.cb-slideshow li:nth-child(6) div {
animation-delay: 30s;
}
#keyframes imageAnimation {
0% { opacity: 0; animation-timing-function: ease-in; }
8% { opacity: 1; animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
.no-cssanimations .cb-slideshow li span{
opacity: 1;
}
#media screen and (max-width: 1140px) {
.cb-slideshow li div h3 { font-size: 140px }
}
#media screen and (max-width: 600px) {
.cb-slideshow li div h3 { font-size: 80px }
}
#keyframes imageAnimation {
0% {
opacity: 0;
animation-timing-function: ease-in;
}
8% {
opacity: 1;
transform: scale(1.05);
animation-timing-function: ease-out;
}
17% {
opacity: 1;
transform: scale(1.1) rotate(3deg);
}
25% {
opacity: 0;
transform: scale(1.1) rotate(3deg);
}
100% { opacity: 0 }
}
</head>
</style>
<ul class="cb-slideshow">
<li><span>Image 01</span></li>
<li><span>Image 02</span></li>
<li><span>Image 03</span></li>
<li><span>Image 04</span></li>
<li><span>Image 05</span></li>
<li><span>Image 06</span></li>
</ul>
Related
How can I make this animated word cycle (made up of absolute positioned spans) to wrap correctly as if it were a regular word inside .sentence? Maybe it's possible to add a ghost inline element with a fixed width (the width of the larger word in the cycle)?
/*Body*/
body {
background-color: #00abe9;
font-family: 'Raleway', sans-serif;
}
/*Heading1*/
h1 {
color: #fff;
font-size: 44px;
margin-top: 40px;
text-align: center;
}
/*Sentence*/
.sentence {
color: #222;
font-size: 30px;
text-align: left;
}
/*Wrapper*/
.wrapper {
background-color: #f5f5f5;
font-family: 'Raleway', sans-serif;
margin: 100px auto;
padding: 40px 40px;
position: relative;
width: 70%;
}
/*Vertical Sliding*/
.slidingVertical {
display: inline;
text-indent: 8px;
}
.slidingVertical span {
animation: topToBottom 12.5s linear infinite 0s;
-ms-animation: topToBottom 12.5s linear infinite 0s;
-webkit-animation: topToBottom 12.5s linear infinite 0s;
color: #00abe9;
opacity: 0;
overflow: hidden;
position: absolute;
}
.slidingVertical span:nth-child(2) {
animation-delay: 2.5s;
-ms-animation-delay: 2.5s;
-webkit-animation-delay: 2.5s;
}
.slidingVertical span:nth-child(3) {
animation-delay: 5s;
-ms-animation-delay: 5s;
-webkit-animation-delay: 5s;
}
.slidingVertical span:nth-child(4) {
animation-delay: 7.5s;
-ms-animation-delay: 7.5s;
-webkit-animation-delay: 7.5s;
}
.slidingVertical span:nth-child(5) {
animation-delay: 10s;
-ms-animation-delay: 10s;
-webkit-animation-delay: 10s;
}
/*topToBottom Animation*/
#-moz-keyframes topToBottom {
0% {
opacity: 0;
}
5% {
opacity: 0;
-moz-transform: translateY(-50px);
}
10% {
opacity: 1;
-moz-transform: translateY(0px);
}
25% {
opacity: 1;
-moz-transform: translateY(0px);
}
30% {
opacity: 0;
-moz-transform: translateY(50px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#-webkit-keyframes topToBottom {
0% {
opacity: 0;
}
5% {
opacity: 0;
-webkit-transform: translateY(-50px);
}
10% {
opacity: 1;
-webkit-transform: translateY(0px);
}
25% {
opacity: 1;
-webkit-transform: translateY(0px);
}
30% {
opacity: 0;
-webkit-transform: translateY(50px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#-ms-keyframes topToBottom {
0% {
opacity: 0;
}
5% {
opacity: 0;
-ms-transform: translateY(-50px);
}
10% {
opacity: 1;
-ms-transform: translateY(0px);
}
25% {
opacity: 1;
-ms-transform: translateY(0px);
}
30% {
opacity: 0;
-ms-transform: translateY(50px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
<section class="wrapper">
<h2 class="sentence">Our product is
<div class="slidingVertical">
<span>Amazing.</span>
<span>Beautiful.</span>
<span>Cute.</span>
<span>Delightful.</span>
<span>Emotional.</span>
</div>
</h2>
</section>
View the CodePen.
Don't make all the words position:absolute. Keep one of them position:relative (the longest one) so you can have a correct wrapping:
/*Body*/
body {
background-color: #00abe9;
font-family: 'Raleway', sans-serif;
}
/*Heading1*/
h1 {
color: #fff;
font-size: 44px;
margin-top: 40px;
text-align: center;
}
/*Sentence*/
.sentence {
color: #222;
font-size: 30px;
text-align: left;
}
/*Wrapper*/
.wrapper {
background-color: #f5f5f5;
font-family: 'Raleway', sans-serif;
margin: 100px auto;
padding: 40px 40px;
position: relative;
width: 70%;
}
/*Vertical Sliding*/
.slidingVertical {
display: inline-block;
position:relative; /* added */
vertical-align: text-top; /* added */
}
.slidingVertical span {
animation: topToBottom 12.5s linear infinite 0s;
color: #00abe9;
opacity: 0;
overflow: hidden;
position: absolute;
left:0; /* added */
}
/* added */
.slidingVertical span:nth-child(4) {
position:relative;
display:inline-block;
}
/**/
.slidingVertical span:nth-child(2) {
animation-delay: 2.5s;
}
.slidingVertical span:nth-child(3) {
animation-delay: 5s;
}
.slidingVertical span:nth-child(4) {
animation-delay: 7.5s;
}
.slidingVertical span:nth-child(5) {
animation-delay: 10s;
}
/*topToBottom Animation*/
#keyframes topToBottom {
0% {
opacity: 0;
}
5% {
opacity: 0;
transform: translateY(-50px);
}
10% {
opacity: 1;
transform: translateY(0px);
}
25% {
opacity: 1;
transform: translateY(0px);
}
30% {
opacity: 0;
transform: translateY(50px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
<section class="wrapper">
<h2 class="sentence">Our product is
<div class="slidingVertical">
<span>Amazing.</span>
<span>Beautiful.</span>
<span>Cute.</span>
<span>Delightful.</span>
<span>Emotional.</span>
</div>
</h2>
</section>
Super new to text animation and coding in general - so apologies in advance! I'm currently trying to center this entire text animation on a header section of a website. I've been playing around with the css, but I'm having a hard time getting it to look centered and stay horizontal and look nice on mobile. Any advice or info would be great :) Thanks so much!
Here it is!
https://codepen.io/kamwam/pen/PoYzNqw
.rw-wrapper {
width: 80%;
position: absolute;
text-align: center;
margin: 110px auto 0 auto;
font-family: 'Playfair Display';
font-weight: 600;
padding: 10px;
}
.after {
margin-left: 134px;
}
.rw-sentence {
margin: 0;
text-align: left;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
.rw-sentence span {
color: #333;
font-size: 200%;
font-weight: 400;
}
.rw-words {
display: inline;
text-indent: 10px;
}
.rw-words-1 span {
position: absolute;
opacity: 0;
overflow: hidden;
color: #0076bb;
-webkit-animation: rotateWord 18s linear infinite 0s;
-ms-animation: rotateWord 18s linear infinite 0s;
animation: rotateWord 18s linear infinite 0s;
}
.rw-words-1 span:nth-child(2) {
-webkit-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
color: #0076bb;
}
.rw-words-1 span:nth-child(3) {
-webkit-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #0076bb;
}
.rw-words-1 span:nth-child(4) {
-webkit-animation-delay: 9s;
-ms-animation-delay: 9s;
animation-delay: 9s;
color: #0076bb;
}
.rw-words-1 span:nth-child(5) {
-webkit-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
color: #0076bb;
}
.rw-words-1 span:nth-child(6) {
-webkit-animation-delay: 15s;
-ms-animation-delay: 15s;
animation-delay: 15s;
color: #0076bb;
}
#-webkit-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#-ms-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-ms-transform: translateY(-30px);
}
5% {
opacity: 1;
-ms-transform: translateY(0px);
}
17% {
opacity: 1;
-ms-transform: translateY(0px);
}
20% {
opacity: 0;
-ms-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#media screen and (max-width: 768px) {
.rw-sentence {
font-size: 18px;
}
}
#media screen and (max-width: 320px) {
.rw-sentence {
font-size: 9px;
}
}
<link href='https://fonts.googleapis.com/css?family=Playfair Display' rel='stylesheet' type='text/css'>
<section class="rw-wrapper">
<div class="rw-sentence">
<span>Ties made for your</span>
<div class="rw-words rw-words-1">
<span>outdoor</span>
<span>modern</span>
<span>vintage</span>
<span>garden</span>
<span>nautical</span>
<span>modern</span>
</div>
<span class="after"> wedding</span>
</div>
</section>
I forked your pen here.
I removed most margin and padding and here is what I have (I commented what I did in the code) :
.rw-sentence {
text-align: left;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
/* max-content make the width fit the content "at is largest" (without wrap) */
/* this allow margin: 0 auto; to center it without white space
(It fit the box to the text and center the box) */
width: max-content;
margin: 0 auto;
/* This is also necessary, otherwise you'd have to compensate for the difference
in height with the container one way or another */
height: 100%;
}
.rw-sentence span {
color: #333;
font-size: 200%;
/* I fiddled to find the right line height to fit the height of the container */
/* not sure that's "best practice" but it work :) */
line-height: 140%;
font-weight: 400;
}
Edit
Read afterward about the responsive issue.
html {
/* define a root font-size */
/* using unit like vw (a % of the width of the viewport
or vmax (a % of the largest between the height and width of the viewport
can make your design more fluid as it will adjust with the device viewport */
font-size: 16px;
}
/* I set this container font-size to "1 time the root font-size"
The font size in your span (200%) is 200% of this font-size here
If you use 'rem' for other length (like width, height ..) it will still
be representing the root font-size (here x time 16px) */
.rw-sentence {
font-size: 1rem;
/* This is the values I chose for the media queries but feel free to
play around with those values, trying 'vw', 'vmax', using rem ...*/
#media screen and (max-width: 860px) {
html {
font-size: 10px;
}
}
#media screen and (max-width: 400px) {
html {
font-size: 8px;
}
}
you have to just edit the following css code
.rw-sentence {
text-align: center;
}
#media screen and (max-width: 768px) {
.rw-sentence {
font-size: 16px;
}
}
#media screen and (max-width: 320px) {
.rw-sentence {
font-size: 12px;
}
}
and never use font size less then 12px in mobile view.
Apply Flexbox layout to the .rw-wrapper div. Then the contents can easily be centered using align-items and justify-content.
.rw-wrapper {
display: flex; /* turn this into a `flexbox` container */
align-items: center; /* aligns content vertically */
justify-content: center; /* aligns content horizontally */
}
A great resource on Flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.rw-wrapper {
border: 1px solid blue; /* just so you can see the div in question easier, remove this */
display: flex; /* turn this into a `flexbox` container */
align-items: center; /* aligns content vertically */
justify-content: center; /* aligns content horizontally */
width: 80%;
position: absolute;
text-align: center;
margin: 110px auto 0 auto;
font-family: 'Playfair Display';
font-weight: 600;
padding: 10px;
}
.after {
margin-left: 134px;
}
.rw-sentence {
margin: 0;
text-align: left;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
.rw-sentence span {
color: #333;
font-size: 200%;
font-weight: 400;
}
.rw-words {
display: inline;
text-indent: 10px;
}
.rw-words-1 span {
position: absolute;
opacity: 0;
overflow: hidden;
color: #0076bb;
-webkit-animation: rotateWord 18s linear infinite 0s;
-ms-animation: rotateWord 18s linear infinite 0s;
animation: rotateWord 18s linear infinite 0s;
}
.rw-words-1 span:nth-child(2) {
-webkit-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
color: #0076bb;
}
.rw-words-1 span:nth-child(3) {
-webkit-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #0076bb;
}
.rw-words-1 span:nth-child(4) {
-webkit-animation-delay: 9s;
-ms-animation-delay: 9s;
animation-delay: 9s;
color: #0076bb;
}
.rw-words-1 span:nth-child(5) {
-webkit-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
color: #0076bb;
}
.rw-words-1 span:nth-child(6) {
-webkit-animation-delay: 15s;
-ms-animation-delay: 15s;
animation-delay: 15s;
color: #0076bb;
}
#-webkit-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#-ms-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-ms-transform: translateY(-30px);
}
5% {
opacity: 1;
-ms-transform: translateY(0px);
}
17% {
opacity: 1;
-ms-transform: translateY(0px);
}
20% {
opacity: 0;
-ms-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#media screen and (max-width: 768px) {
.rw-sentence {
font-size: 18px;
}
}
#media screen and (max-width: 320px) {
.rw-sentence {
font-size: 9px;
}
}
<link href='https://fonts.googleapis.com/css?family=Playfair Display' rel='stylesheet' type='text/css'>
<section class="rw-wrapper">
<div class="rw-sentence">
<span>Ties made for your</span>
<div class="rw-words rw-words-1">
<span>outdoor</span>
<span>modern</span>
<span>vintage</span>
<span>garden</span>
<span>nautical</span>
<span>modern</span>
</div>
<span class="after"> wedding</span>
</div>
</section>
You could use CSS Grid for this, all you need to change in your code is as below and it will work!
.rw-wrapper {
display: grid;
width: 100%;
height: 100vh;
}
.rw-sentence {
margin: auto;
max-width: 300px;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
Happy coding. :)
Use left: 50%; with transform: translateX(-50%); to center the absolutely positioned element regardless of its width. And do not mention any width for <section class="rw-wrapper">.
Also, you don't have to reduce font-size so drastically for mobile resolutions. I Have not reduced it at all. See below:
.rw-wrapper {
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 110px;
font-family: 'Playfair Display';
font-weight: 600;
padding: 10px;
}
.after {
margin-left: 134px;
}
.rw-sentence {
margin: 0;
text-align: center;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
.rw-sentence span {
color: #333;
font-size: 200%;
font-weight: 400;
}
.rw-words {
display: inline;
text-indent: 10px;
}
.rw-words-1 span {
position: absolute;
opacity: 0;
overflow: hidden;
color: #0076bb;
-webkit-animation: rotateWord 18s linear infinite 0s;
-ms-animation: rotateWord 18s linear infinite 0s;
animation: rotateWord 18s linear infinite 0s;
}
.rw-words-1 span:nth-child(2) {
-webkit-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
color: #0076bb;
}
.rw-words-1 span:nth-child(3) {
-webkit-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #0076bb;
}
.rw-words-1 span:nth-child(4) {
-webkit-animation-delay: 9s;
-ms-animation-delay: 9s;
animation-delay: 9s;
color: #0076bb;
}
.rw-words-1 span:nth-child(5) {
-webkit-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
color: #0076bb;
}
.rw-words-1 span:nth-child(6) {
-webkit-animation-delay: 15s;
-ms-animation-delay: 15s;
animation-delay: 15s;
color: #0076bb;
}
#-webkit-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#-ms-keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-ms-transform: translateY(-30px);
}
5% {
opacity: 1;
-ms-transform: translateY(0px);
}
17% {
opacity: 1;
-ms-transform: translateY(0px);
}
20% {
opacity: 0;
-ms-transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes rotateWord {
0% {
opacity: 0;
}
2% {
opacity: 0;
-webkit-transform: translateY(-30px);
transform: translateY(-30px);
}
5% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
17% {
opacity: 1;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
20% {
opacity: 0;
-webkit-transform: translateY(30px);
transform: translateY(30px);
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#media screen and (min-width: 576px) {
.rw-wrapper {
white-space: nowrap;
}
}
<link href='https://fonts.googleapis.com/css?family=Playfair Display' rel='stylesheet' type='text/css'>
<section class="rw-wrapper">
<div class="rw-sentence">
<span>Ties made for your</span>
<div class="rw-words rw-words-1">
<span>outdoor</span>
<span>modern</span>
<span>vintage</span>
<span>garden</span>
<span>nautical</span>
<span>modern</span>
</div>
<span class="after"> wedding</span>
</div>
</section>
Try this.
Update this CSS
rw-sentence #Class
.rw-sentence {
margin: 0;
text-align: center;;
text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}
I would recomend using style="margin-left: 10px" just inside your <span> so that it looks like:
<span style="margin-left: 10px">
And then just change the ten pixels until the text is centered. I tried to use align='center' and text-align but they do not work.
So I have created a rough nav bar at the top of the page, on top (I thought) of the picture slideshow, but for some reason the background color of the navigation bar fades to transparent as the slideshow changes images. How do I stop it from doing this, and set it to a fixed opacity? Thankyou.
body,
div,
dl,
dt,
dd,
ul,
ol,
li,
h1,
h2,
h3,
h4,
h5,
h6,
pre,
form,
fieldset,
input,
textarea,
p,
blockquote,
th,
td {
margin: 0;
padding: 0;
}
.cb-slideshow,
.cb-slideshow:after {
position: fixed;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 0;
}
.cb-slideshow:after {
content: '';
background: transparent url(../../../images/pattern.png) repeat top left;
}
.cb-slideshow li span {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
background-size: cover;
background-position: 50% 50%;
background-repeat: none;
opacity: 0;
z-index: -10;
-webkit-backface-visibility: visible;
-webkit-animation: imageAnimation 30s linear infinite 0s;
-moz-animation: imageAnimation 30s linear infinite 0s;
-o-animation: imageAnimation 30s linear infinite 0s;
-ms-animation: imageAnimation 30s linear infinite 0s;
animation: imageAnimation 30s linear infinite 0s;
}
.cb-slideshow li div {
z-index: 3;
position: absolute;
bottom: 30px;
left: 0px;
width: 100%;
text-align: center;
opacity: 0;
color: #fff;
-webkit-animation: titleAnimation 30s linear infinite 0s;
-moz-animation: titleAnimation 30s linear infinite 0s;
-o-animation: titleAnimation 30s linear infinite 0s;
-ms-animation: titleAnimation 30s linear infinite 0s;
animation: titleAnimation 30s linear infinite 0s;
}
.cb-slideshow li div h3 {
font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
font-size: 240px;
padding: 0;
line-height: 200px;
z-index: -7;
}
.cb-slideshow li:nth-child(1) span {
background-image: url(../images/image%201.jpg);
z-index: -7;
}
.cb-slideshow li:nth-child(2) span {
background-image: url(../images/image%202.jpg);
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
z-index: -7;
}
.cb-slideshow li:nth-child(3) span {
background-image: url(../images/image%203.jpg);
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-o-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
z-index: -7;
}
.cb-slideshow li:nth-child(4) span {
background-image: url(../images/image%204.jpg);
-webkit-animation-delay: 18s;
-moz-animation-delay: 18s;
-o-animation-delay: 18s;
-ms-animation-delay: 18s;
animation-delay: 18s;
z-index: -7;
}
.cb-slideshow li:nth-child(5) span {
background-image: url(../images/image%205.jpg);
-webkit-animation-delay: 24s;
-moz-animation-delay: 24s;
-o-animation-delay: 24s;
-ms-animation-delay: 24s;
animation-delay: 24s;
z-index: -7;
}
.cb-slideshow li:nth-child(2) div {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
z-index: -7;
}
.cb-slideshow li:nth-child(3) div {
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-o-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
z-index: -7;
}
.cb-slideshow li:nth-child(4) div {
-webkit-animation-delay: 18s;
-moz-animation-delay: 18s;
-o-animation-delay: 18s;
-ms-animation-delay: 18s;
animation-delay: 18s;
z-index: -7;
}
.cb-slideshow li:nth-child(5) div {
-webkit-animation-delay: 24s;
-moz-animation-delay: 24s;
-o-animation-delay: 24s;
-ms-animation-delay: 24s;
animation-delay: 24s;
z-index: -7;
}
/* Animation for the slideshow images */
#-webkit-keyframes imageAnimation {
0% {
opacity: 0;
-webkit-animation-timing-function: ease-in;
}
8% {
opacity: 1;
-webkit-animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}
#-moz-keyframes imageAnimation {
0% {
opacity: 0;
-moz-animation-timing-function: ease-in;
}
8% {
opacity: 1;
-moz-animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}
#-o-keyframes imageAnimation {
0% {
opacity: 0;
-o-animation-timing-function: ease-in;
}
8% {
opacity: 1;
-o-animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}
#-ms-keyframes imageAnimation {
0% {
opacity: 0;
-ms-animation-timing-function: ease-in;
}
8% {
opacity: 1;
-ms-animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}
#keyframes imageAnimation {
0% {
opacity: 0;
animation-timing-function: ease-in;
}
8% {
opacity: 1;
animation-timing-function: ease-out;
}
17% {
opacity: 1
}
25% {
opacity: 0
}
100% {
opacity: 0
}
}
/* Animation for the title */
#-webkit-keyframes titleAnimation {
0% {
opacity: 0
}
8% {
opacity: 1
}
17% {
opacity: 1
}
19% {
opacity: 0
}
100% {
opacity: 0
}
}
#-moz-keyframes titleAnimation {
0% {
opacity: 0
}
8% {
opacity: 1
}
17% {
opacity: 1
}
19% {
opacity: 0
}
100% {
opacity: 0
}
}
#-o-keyframes titleAnimation {
0% {
opacity: 0
}
8% {
opacity: 1
}
17% {
opacity: 1
}
19% {
opacity: 0
}
100% {
opacity: 0
}
}
#-ms-keyframes titleAnimation {
0% {
opacity: 0
}
8% {
opacity: 1
}
17% {
opacity: 1
}
19% {
opacity: 0
}
100% {
opacity: 0
}
}
#keyframes titleAnimation {
0% {
opacity: 0
}
8% {
opacity: 1
}
17% {
opacity: 1
}
19% {
opacity: 0
}
100% {
opacity: 0
}
}
/* Show at least something when animations not supported */
.no-cssanimations .cb-slideshow li span {
opacity: 1;
}
#media screen and (max-width: 1140px) {
.cb-slideshow li div h3 {
font-size: 140px
}
}
#media screen and (max-width: 600px) {
.cb-slideshow li div h3 {
font-size: 80px
}
}
.logo {
position: relative;
width: 120px;
top: 30px;
float: left;
margin-left: 25px;
}
/* CSS Document */
a {
font-family: Arial;
text-decoration: none;
color: white;
font-size: 15px;
}
ul {
list-style-type: none;
}
li {
display: inline;
padding: 10px;
}
.list {
position: relative;
margin-top: 40px;
float: right;
}
.navbar {
background-color: black;
height: 100px;
width: 100%;
z-index: 6;
}
<div class="navbar">
<img class="logo" src="images/hk white.png" />
<ul class="list">
<a class="alist" href="index.html">
<li class="listli" id="home"><strong>HOME</strong>
</li>
</a><strong>
<a class="alist" href="products.html"><li class="listli" id="about">PRODUCTS</li></a>
<a class="alist" href="blog.html"><li class="listli" id="work">BLOG</li></a>
<a class="alist" href="contact.html"><li class="listli" id="contact">CONTACT</li></a>
</ul>
</div>
<ul class="cb-slideshow">
<li><span>Image 01</span><div><h3>hon·our</h3></div></li>
<li><span>Image 02</span><div><h3>pas·sion</h3></div></li>
<li><span>Image 03</span><div><h3>bal·ance</h3></div></li>
<li><span>Image 04</span><div><h3>re·spec·t</h3></div></li>
<li><span>Image 05</span><div><h3>cul·ture</h3></div></li>
</ul>
Let me know if you also need the JS file.
Hi
try to change this and it should work.
HTML
<li>
<span>
<img src="ImageHere"></span>
<div class="slides"><h3>hon·our</h3></div>
</li>
CSS
.cb-slideshow li .slides h3 {
font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
font-size: 240px;
z-index: 0;
position:absolute;
top:50%;
}
Fiddle demo here
I hope this helps
I'm trying to animate a single word in the middle of a sentence using CSS and HTML. I'm want the word to animate downward and fade out, as a new word fades in from above. My problem is that the rest of the sentence after the animating word isn't spacing correctly. As you can see below, the animating word is overlapping the rest of the sentence.
Here's a screencast of the animation: https://www.dropbox.com/s/svjrbqug3gjsg2s/movie.mov?dl=0
And here's my code so far:
<html>
<head>
<link rel="stylesheet" type="text/css" href="rotate.css">
</head>
<section class="rw-wrapper">
<span>The</span>
<div class="rw-words rw-words-1">
<span>inspiration</span>
<span>accountability</span>
<span>results</span>
<span>community</span>
<span>experience</span>
<span>coaching</span>
</div>
<span>you're looking for.</span>
</section>
</html>
CSS:
.rw-wrapper{
width: 80%;
position: relative;
margin: 110px auto 0 auto;
font-family: 'Bree Serif';
padding: 10px;
}
.rw-words{
display: inline;
text-indent: 2px;
}
.rw-words-1 span{
position: absolute;
opacity: 0;
overflow: hidden;
color: #6b969d;
-webkit-animation: rotateWord 18s linear infinite 0s;
-ms-animation: rotateWord 18s linear infinite 0s;
animation: rotateWord 18s linear infinite 0s;
}
.rw-words-1 span:nth-child(2) {
-webkit-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
color: #6b969d;
}
.rw-words-1 span:nth-child(3) {
-webkit-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
color: #6b969d;
}
.rw-words-1 span:nth-child(4) {
-webkit-animation-delay: 9s;
-ms-animation-delay: 9s;
animation-delay: 9s;
color: #6b969d;
}
.rw-words-1 span:nth-child(5) {
-webkit-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
color: #6b969d;
}
.rw-words-1 span:nth-child(6) {
-webkit-animation-delay: 15s;
-ms-animation-delay: 15s;
animation-delay: 15s;
color: #6b969d;
}
#-webkit-keyframes rotateWord {
0% { opacity: 0; }
2% { opacity: 0; -webkit-transform: translateY(-30px); }
5% { opacity: 1; -webkit-transform: translateY(0px);}
17% { opacity: 1; -webkit-transform: translateY(0px); }
20% { opacity: 0; -webkit-transform: translateY(30px); }
80% { opacity: 0; }
100% { opacity: 0; }
}
#-ms-keyframes rotateWord {
0% { opacity: 0; }
2% { opacity: 0; -ms-transform: translateY(-30px); }
5% { opacity: 1; -ms-transform: translateY(0px);}
17% { opacity: 1; -ms-transform: translateY(0px); }
20% { opacity: 0; -ms-transform: translateY(30px); }
80% { opacity: 0; }
100% { opacity: 0; }
}
#keyframes rotateWord {
0% { opacity: 0; }
2% { opacity: 0; -webkit-transform: translateY(-30px); transform: translateY(-30px); }
5% { opacity: 1; -webkit-transform: translateY(0px); transform: translateY(0px);}
17% { opacity: 1; -webkit-transform: translateY(0px); transform: translateY(0px); }
20% { opacity: 0; -webkit-transform: translateY(30px); transform: translateY(30px); }
80% { opacity: 0; }
100% { opacity: 0; }
}
#media screen and (max-width: 768px){
.rw-sentence { font-size: 18px; }
}
#media screen and (max-width: 320px){
.rw-sentence { font-size: 9px; }
}
How can I use CSS to get the rest of my sentence to space properly for the animating word?
You can do this in pure CSS by animating the max-width of the individual spans. Here’s a CodePen, and here’s the CSS (prefixes removed for clarity. To get them back just click the little 'View Compiled' button on CodePen)
.rw-wrapper{
width: 80%;
position: relative;
margin: 110px auto 0 auto;
font-family: 'Bree Serif';
padding: 10px;
}
.rw-words{
display: inline-block;
text-indent: 2px;
}
.rw-words-1 span{
max-width: 0;
display: inline-block;
opacity: 0;
overflow: hidden;
color: #6b969d;
margin-left: -4px;
animation: rotateWord 18s linear infinite 0s;
}
.rw-words-1 span:nth-child(2) {
animation-delay: 3s;
color: #6b969d;
}
.rw-words-1 span:nth-child(3) {
animation-delay: 6s;
color: #6b969d;
}
.rw-words-1 span:nth-child(4) {
animation-delay: 9s;
color: #6b969d;
}
.rw-words-1 span:nth-child(5) {
animation-delay: 12s;
color: #6b969d;
}
.rw-words-1 span:nth-child(6) {
animation-delay: 15s;
color: #6b969d;
}
#keyframes rotateWord {
0% { opacity: 0; max-width: 0;}
2% { opacity: 0; max-width: 0; transform: translateY(-30px); }
5% { opacity: 1; max-width: 200px; transform: translateY(5px);}
17% { opacity: 1; max-width: 200px; transform: translateY(5px); }
20% { opacity: 0; max-width: 0; transform: translateY(30px); }
80% { opacity: 0; max-width: 0; }
100% { opacity: 0; max-width: 0; }
}
#media screen and (max-width: 768px){
.rw-sentence { font-size: 18px; }
}
#media screen and (max-width: 320px){
.rw-sentence { font-size: 9px; }
}
It’s a little bit hacky, but it works! No JS required.
I removed the position: absolute and added max-width to the animation. Presto!
Here's a solution that uses JavaScript:
Example Fiddle
Here's the code that runs it:
JavaScript
var spans = document.querySelectorAll('.rw-words span'),
maxwidth = 0,
words = document.querySelector('.rw-words');
for (var i=0,l=spans.length;i<l;i++){
console.log(i + ' width: ' + spans[i].offsetWidth)
maxwidth = spans[i].offsetWidth > maxwidth ? spans[i].offsetWidth : maxwidth;
}
words.style.width = maxwidth + 'px'
CSS
.rw-words{
display: inline-block;
vertical-align: top;
text-indent: 2px;
}
EDIT
Here's some much cleaner JavaScript that achieves the same thing:
var spans = [].slice.call(document.querySelectorAll('.rw-words span')),
words = document.querySelector('.rw-words'),
maxwidth = Math.max.apply(null, spans.map(function (item) {
return item.offsetWidth;
}));
words.style.width = maxwidth + 'px'
Set the width to the width of the largest element
var rwWords = document.querySelector('.rw-words-1');
var largest = [].slice.call(rwWords.querySelectorAll('span')).reduce(function (acc, el) {
var len = el.textContent.trim().length;
var cur = acc.textContent.trim().length;
return len > cur ? el : acc;
});
rwWords.style.width = window.getComputedStyle(largest).width;
and center the words with
transform: translate(-50%, 0);
JSFiddle Demo: http://jsfiddle.net/e697j5p2/1/
Please have a look at http://facelesstolegendary.com
I looked at several posts here and saw that I need to add the -webkit- prefix to my transforms, etc.
I did that, but it still does not work on iOS. It does work on my desktop browsers.
Here's the relevant code:
.cb-slideshow,
.cb-slideshow:after {
position: fixed;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 0;
}
.cb-slideshow:after {
content: '';
background: transparent url(pattern.png) repeat top left;
}
.cb-slideshow li span {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
background-size: cover;
background-position: 50% 50%;
background-repeat: none;
opacity: 0;
-webkit-opacity: 0;
z-index: 0;
animation: imageAnimation 36s linear infinite 0s;
-webkit-animation: imageAnimation 36s linear infinite 0s;
}
.cb-slideshow li div {
z-index: 1000;
position: absolute;
bottom: 30px;
left: 0px;
width: 100%;
text-align: center;
opacity: 0;
-webkit-opacity: 0;
color: #fff;
animation: titleAnimation 36s linear infinite 0s;
-webkit-animation: titleAnimation 36s linear infinite 0s;
}
.cb-slideshow li div h3 {
font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
font-size: 240px;
padding: 0;
line-height: 200px;
}
.cb-slideshow li:nth-child(1) span {
background-image: url(faceless.jpg)
}
.cb-slideshow li:nth-child(2) span {
background-image: url(legendary.jpg);
animation-delay: 6s;
-webkit-animation-delay: 6s;
}
.cb-slideshow li:nth-child(3) span {
background-image: url(faceless.jpg);
animation-delay: 12s;
-webkit-animation-delay: 12s;
}
.cb-slideshow li:nth-child(4) span {
background-image: url(legendary.jpg);
animation-delay: 18s;
-webkit-animation-delay: 18s;
}
.cb-slideshow li:nth-child(5) span {
background-image: url(faceless.jpg);
animation-delay: 24s;
-webkit-animation-delay: 24s;
}
.cb-slideshow li:nth-child(6) span {
background-image: url(legendary.jpg);
animation-delay: 30s;
-webkit-animation-delay: 30s;
}
.cb-slideshow li:nth-child(2) div {
animation-delay: 6s;
-webkit-animation-delay: 6s;
}
.cb-slideshow li:nth-child(3) div {
animation-delay: 12s;
-webkit-animation-delay: 12s;
}
.cb-slideshow li:nth-child(4) div {
animation-delay: 18s;
-webkit-animation-delay: 18s;
}
.cb-slideshow li:nth-child(5) div {
animation-delay: 24s;
-webkit-animation-delay: 24s;
}
.cb-slideshow li:nth-child(6) div {
animation-delay: 30s;
-webkit-animation-delay: 30s;
}
.no-cssanimations .cb-slideshow li span{
opacity: 1;
-webkit-opacity: 1;
}
#media screen and (max-width: 1140px) {
.cb-slideshow li div h3 { font-size: 140px }
}
#media screen and (max-width: 600px) {
.cb-slideshow li div h3 { font-size: 80px }
}
#keyframes imageAnimation {
0% {
opacity: 0;
-webkit-opacity: 0;
animation-timing-function: ease-in;
-webkit-animation-timing-function: ease-in;
}
8% {
opacity: 1;
-webkit-opacity: 1;
transform: scale(1.05);
-webkit-transform: scale(1.05);
animation-timing-function: ease-out;
-webkit-animation-timing-function: ease-out;
}
17% {
opacity: 1;
-webkit-opacity: 1;
transform: scale(1.1) rotate(3deg);
-webkit-transform: scale(1.1) rotate(3deg);
}
25% {
opacity: 0;
-webkit-opacity: 0;
transform: scale(1.1) rotate(3deg);
-webkit-transform: scale(1.1) rotate(3deg);
}
100% {
opacity: 0
-webkit-opacity: 0
}
}
<ul class="cb-slideshow">
<li>
<span>Image 01</span>
<div>
</div>
</li>
<li>
<span>Image 02</span>
<div>
</div>
</li>
<li>
<span>Image 03</span>
<div>
</div>
</li>
<li>
<span>Image 04</span>
<div>
</div>
</li>
<li>
<span>Image 05</span>
<div>
</div>
</li>
<li>
<span>Image 06</span>
<div>
</div>
</li>
</ul>
You need to prefix your #keyframes with -webkit-, and include the -webkit-prefixed animations and transitions there, instead of including them in your original #keyframes:
#keyframes imageAnimation {
0% {
opacity: 0;
-webkit-opacity: 0;
animation-timing-function: ease-in;
-webkit-animation-timing-function: ease-in;
}
becomes:
#-webkit-keyframes imageAnimation {
0% {
-webkit-opacity: 0;
-webkit-animation-timing-function: ease-in;
}
#keyframes imageAnimation {
0% {
opacity: 0;
animation-timing-function: ease-in;
}
and so on.
Did you use -webkit-overflow-scrolling: touch; elsewhere? Try to delete it.