Minimizing iOS Mail app breaks z-index in CSS animation - html

Edit: I'm now confident that this is related to the z-index property of the arrows. If the z-index of the left arrow is higher than the right arrow, the left arrow image will be inserted on the right. If the z-index of the right arrow is higher or equal to the left arrow, the right arrow will be inserted on the right. I still have no idea why this is happening and why it won't just put the images where I tell it to.
Original:
I'm creating an email with a carousel of images that should slide back and forth when the user clicks on arrows to the sides or tabs at the bottom. But I'm seeing some strange behavior in the iOS native mail app and it's making me crazy. When I first receive and open the email, everything works the way it's supposed to. But if I lock my phone or even just minimize the Mail app and reopen it, the arrows will start breaking.
I insert the arrows with a content(url) property on an ::after psuedo-element. The most common error is the right-facing arrow showing up on the left side when all but the first frame is showing. But sometimes it's the first frame that has the wrong arrow and as soon as I change to another frame, the correct one comes back. I also can see the left arrow flickering in before being replaced by the right arrow. Sometimes the top half of the arrow is correct and the bottom half is wrong. It's all very hard to pin down and very frustrating.
I've seen recommendations to add -webkit-backface-visibility: hidden; (which didn't work) and -webkit-perspective: 1000; (which breaks my absolute positioning on the arrows) and -webkit-transform: translateZ(0); (which also breaks my absolute positioning) to the parent.
Here's a gif of what I'm seeing in my app: https://i.imgur.com/OjoTIk9.gifv
Here's my full HTML and CSS:
<style type="text/css">
table {border-spacing:0px !important;}
table, tr, td {width:100% !important;max-width:580px;}
.full-width {
width:100% !important;}
.autoHeight {
height:auto !important;
}
/*** Carousel CSS */
#media screen and (-webkit-min-device-pixel-ratio: 0) {
/* bugfix for Android 4.4 to support e ~ y */
body {
-webkit-animation: bugfix infinite 1s;
}
#-webkit-keyframes bugfix {
from {
padding: 0;
}
to {
padding: 0;
}
}
#supports (position:relative) {
/*.container {
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
}
.container label {position: absolute !important; z-index: 5000 !important;}*/
/* Hide Fallback content first */
.fallback {
display: none;
}
.carousel {
display: block !important;
max-height: none !important;
position: relative;
}
div[class~="aolmail_carousel"] {
display: none !important;
}
div[class~="aolmail_fallback"] {
display: block !important;
max-height: none !important;
position: relative;
}
/*
Selective blocking for clients.
- Samsung (#MessageViewBody) - no absolute positioning
- Comcast/Zimbra (body.MsgBody) - inconsistent CSS support
*/
#MessageViewBody .fallback,
body.MsgBody .fallback {
display: block;
}
#MessageViewBody .carousel,
body.MsgBody .carousel {
display: none !important;
}
input {
display: none;
}
.carousel a {
width: 100%;
display: block;
overflow: hidden;
}
.carousel .car-frames img {
display: block!important;
width: 100% !important;
height: auto !important;
}
.carousel.responsive {
width: 100% !important;
}
.carousel.slide a {
position: absolute;
top: 0px;
left: 0px;
opacity: 1;
width: 100%;
-webkit-animation: slide-anim 12s linear infinite;
}
.carousel.slide a:nth-child(1) {
position: relative;
-webkit-animation-delay: -13s;
}
.carousel.slide a:nth-child(2) {
-webkit-animation-delay: -10s;
}
.carousel.slide a:nth-child(3) {
-webkit-animation-delay: -7s;
}
.carousel.slide a:nth-child(4) {
-webkit-animation-delay: -4s;
}
/* iOS doesn't like negative delay with translates (transform:translateX(100%);) */
/* So we use margin although it is less "smooth" */
#-webkit-keyframes slide-anim {
/* start slide in */
0% {
margin-left: 100%;
}
/* end slide in */
5% {
margin-left: 0%;
}
/* start slide out */
25% {
margin-left: 0%;
}
/* end slide out */
30% {
margin-left: -100%;
}
/* start slide out */
75% {
margin-left: -100%;
}
/* end slide out */
80% {
margin-left: -200%;
}
100% {
margin-left: -200%;
}
/* end slide out */
}
.carousel.slide .car-radio:checked~.car-cont .car-frames {
position: relative;
left: 0px;
top: 0px;
width: 400% !important;
transition: left 1s;
}
.carousel.slide .car-radio2:checked~.car-cont .car-frames {
left: -100%;
}
.carousel.slide .car-radio3:checked~.car-cont .car-frames {
left: -200%;
}
.carousel.slide .car-radio4:checked~.car-cont .car-frames {
left: -300%;
}
.carousel.slide .car-radio:checked~.car-cont a {
width: 25%;
}
.carousel.slide .car-radio:checked~.car-cont a:nth-child(2) {
position: absolute;
left: 25%;
top: 0px;
}
.carousel.slide .car-radio:checked~.car-cont a:nth-child(3) {
position: absolute;
left: 50%;
top: 0px;
}
.carousel.slide .car-radio:checked~.car-cont a:nth-child(4) {
position: absolute;
left: 75%;
top: 0px;
}
/* Navigation arrows */
.carousel .car-ltn {
z-index: 100;
display: none;
width: 15%;
height: 100%;
position: absolute;
background-color: transparent;
top: 0px;
cursor: pointer;
}
.carousel .car-rtn {
z-index: 100;
display: none;
width: 15%;
height: 100%;
position: absolute;
background-color: transparent;
top: 0px;
cursor: pointer;
}
.car-ltn {
left: 0px;
}
.car-rtn {
right: 0px;
}
.carousel .car-ltn::after {
content: url(https://i.imgur.com/CD2FWkH.png) !important;
width: 0;
height: 0;
position: absolute;
top: 40%;
margin-top: -8px;
-webkit-filter: drop-shadow(1px 1.5px 1px rgba(0,0,0,0.4));
}
.carousel .car-rtn::after {
content: url(https://i.imgur.com/BEpuyhp.png) !important;
width: 0;
height: 0;
position: absolute;
top: 40%;
left: 10%;
margin-top: -8px;
-webkit-filter: drop-shadow(1px 1.5px 1px rgba(0,0,0,0.4));
}
.car-ltn::after {
border-right: 0px solid #ffffff;
left: 25%;
}
.car-rtn::after {
border-left: 0px solid #ffffff;
right: 25%;
}
.carousel #car-cbox-support:checked~.car-cont .car-nav-1 {
display: block;
}
.car-radio2:checked~.car-cont .car-controls .car-nav-2,
.car-radio3:checked~.car-cont .car-controls .car-nav-3,
.car-radio4:checked~.car-cont .car-controls .car-nav-4 {
display: block;
}
.carousel .car-radio:checked~.car-cont,
.carousel .car-radio:checked~.car-cont *,
.carousel .car-radio:checked~.car-thumbnails *,
.car-radio:checked~.car-thumbnails .car-thumb::after
{
-webkit-animation: none;
}
/* Thumbnails */
.car-thumbnails {
z-index: 200;
position:absolute !important;
display:block !important;
bottom:0px;
width:100%;
}
.carousel #car-cbox-support:checked~.car-thumbnails {
display: block !important;
text-align: center;
position: relative;
/*background-color: #473729;*/
}
.carousel .car-thumb {
width: 24%;
opacity: 1;
z-index: 100;
cursor: pointer;
display: inline-block;
margin: 0px;
background-color: rgba(255,255,255,0.5);
}
#-webkit-keyframes focus3-anim {
0% {
background-color: rgba(255,188,46,1);
}
25% {
background-color: rgba(255,255,255,0.5);
}
50% {
background-color: rgba(255,255,255,0.5);
}
75% {
background-color: rgba(255,255,255,0.5);
}
100% {
background-color: rgba(255,188,46,1);
}
}
/* to eliminate use of delay */
#-webkit-keyframes focus3-anim-2 {
0% {
background-color: rgba(255,255,255,0.5);
}
25% {
background-color: rgba(255,188,46,1);
}
50% {
background-color: rgba(255,255,255,0.5);
}
75% {
background-color: rgba(255,255,255,0.5);
}
100% {
background-color: rgba(255,255,255,0.5);
}
}
#-webkit-keyframes focus3-anim-3 {
0% {
background-color: rgba(255,255,255,0.5);
}
25% {
background-color: rgba(255,255,255,0.5);
}
50% {
background-color: rgba(255,188,46,1);
}
75% {
background-color: rgba(255,255,255,0.5);
}
100% {
background-color: rgba(255,255,255,0.5);
}
}
#-webkit-keyframes focus3-anim-4 {
0% {
background-color: rgba(255,255,255,0.5);
}
25% {
background-color: rgba(255,255,255,0.5);
}
50% {
background-color: rgba(255,255,255,0.5);
}
75% {
background-color: rgba(255,188,46,1);
}
100% {
background-color: rgba(255,255,255,0.5);
}
}
#media only screen and (max-width:580px) {
.carousel .car-thumb div span {
display:none !important;
}
.carousel .car-thumb div {
width:15px !important;
height:15px !important;
border-radius: 50%;
margin: auto !important;
}
.carousel .car-thumb {
background-color:transparent !important;
}
.carousel .car-thumbnails {
line-height:50px;
width:70%;
left:15%;
}
.car-thumb:nth-child(1) div {
-webkit-animation: focus3-anim 12s ease-in infinite;
}
.car-thumb:nth-child(2) div {
/*-webkit-animation: focus3-anim 15s linear 5s infinite;*/
-webkit-animation: focus3-anim-2 12s ease-in infinite;
}
.car-thumb:nth-child(3) div {
/*-webkit-animation: focus3-anim 15s linear 10s infinite;*/
-webkit-animation: focus3-anim-3 12s ease-in infinite;
}
.car-thumb:nth-child(4) div {
/*-webkit-animation: focus3-anim 15s linear 10s infinite;*/
-webkit-animation: focus3-anim-4 12s ease-in infinite;
}
.car-radio:checked~.car-thumbnails .car-thumb:nth-child(1) {
background-color: rgba(255,255,255,0.5);
}
.car-radio1:checked~.car-thumbnails .car-thumb:nth-child(1) div {
background-color: rgba(255,188,46,1);
}
.car-radio2:checked~.car-thumbnails .car-thumb:nth-child(2) div,
.car-radio3:checked~.car-thumbnails .car-thumb:nth-child(3) div,
.car-radio4:checked~.car-thumbnails .car-thumb:nth-child(4) div {
background-color: rgba(255,188,46,1);
}
}
#media only screen and (min-width:580px) {
.car-thumb-1 {margin-right:3px !important;}
.car-thumb-2 {margin-right:3px !important;}
.car-thumb-3 {margin-right:3px !important;}
.car-thumb:nth-child(1) {
-webkit-animation: focus3-anim 12s ease-in infinite;
}
.car-thumb:nth-child(2) {
/*-webkit-animation: focus3-anim 15s linear 5s infinite;*/
-webkit-animation: focus3-anim-2 12s ease-in infinite;
}
.car-thumb:nth-child(3) {
/*-webkit-animation: focus3-anim 15s linear 10s infinite;*/
-webkit-animation: focus3-anim-3 12s ease-in infinite;
}
.car-thumb:nth-child(4) {
/*-webkit-animation: focus3-anim 15s linear 10s infinite;*/
-webkit-animation: focus3-anim-4 12s ease-in infinite;
}
.car-radio:checked~.car-thumbnails .car-thumb:nth-child(1) {
background-color: rgba(255,255,255,0.5);
}
.car-radio1:checked~.car-thumbnails .car-thumb:nth-child(1) {
background-color: rgba(255,188,46,1);
}
.car-radio2:checked~.car-thumbnails .car-thumb:nth-child(2),
.car-radio3:checked~.car-thumbnails .car-thumb:nth-child(3),
.car-radio4:checked~.car-thumbnails .car-thumb:nth-child(4){
background-color: rgba(255,188,46,1);
}
}
#media only screen and (max-width: 580px) {
.carousel .car-thumb {
width: 15%;
opacity: 1;
z-index: 100;
cursor: pointer;
display: inline-block;
margin: 0px 0px;
}
.carousel .car-thumb div {
background-color:rgba(255,255,255,0.5);
}
}
/* .car-ltn, .car-rtn {
display:none !important;
} */
/* .car-thumbnails {
display:none !important;
}
.carousel .car-thumb {
display:none !important;
} */
}
}
</style>
<table align="center" bgcolor="#ffffff" valign="middle" width="580" margin="auto" cellpadding="0" cellspacing="0" style="width:580px;border-collapse:collapse;margin:auto;background-color:#ffffff;text-align:center;">
<tr>
<td>
<!-- animated carousel -->
<div class="carousel slide responsive" style="overflow:hidden;width:580px;" width="580">
<!--[if !mso]><!-- -->
<input id="car-cbox-support" type="checkbox" checked="" style="display:none!important">
<input name="car-radio" type="radio" id="car1-radio-1" class="car-radio car-radio1" style="display:none!important">
<input name="car-radio" type="radio" id="car1-radio-2" class="car-radio car-radio2" style="display:none!important">
<input name="car-radio" type="radio" id="car1-radio-3" class="car-radio car-radio3" style="display:none!important">
<input name="car-radio" type="radio" id="car1-radio-4" class="car-radio car-radio4" style="display:none!important">
<!--<![endif]-->
<div class="car-cont" style="position:relative;background-color:#ffffff;">
<div class="car-frames">
<!-- Slide 1 Main Image -->
<img class="full-width autoHeight" src="https://i.imgur.com/j4HpeVl.png" style="display:block;" alt="" border="0">
<!-- Slide 2 Main Image -->
<img class="full-width autoHeight" src="https://i.imgur.com/7OdQqhV.png" style="display:block;" alt="" border="0">
<!-- Slide 3 Main Image -->
<img class="full-width autoHeight" src="https://i.imgur.com/g9pLZbr.png" style="display:block;" alt="" border="0">
<!-- Slide 4 Main Image -->
<img class="full-width autoHeight" src="https://i.imgur.com/ewrZxr5.png" style="display:block;" alt="" border="0">
</div>
<div class="car-controls container">
<!--When slide 1 (car-nav-1) is showing, clicking the left arrow should transition to slide 4 (car1-radio-4) -->
<label for="car1-radio-4" class="car-ltn car-nav-1"></label>
<!--When slide 1 (car-nav-1) is showing, clicking the right arrow should transition to slide 2 (car1-radio-2) -->
<label for="car1-radio-2" class="car-rtn car-nav-1"></label>
<!--When slide 2 (car-nav-2) is showing, clicking the left arrow should transition to slide 1 (car1-radio-1) -->
<label for="car1-radio-1" class="car-ltn car-nav-2"></label>
<!--When slide 2 (car-nav-2) is showing, clicking the right arrow should transition to slide 3 (car1-radio-3) -->
<label for="car1-radio-3" class="car-rtn car-nav-2"></label>
<!--When slide 3 (car-nav-3) is showing, clicking the left arrow should transition to slide 2 (car1-radio-2) -->
<label for="car1-radio-2" class="car-ltn car-nav-3"></label>
<!--When slide 3 (car-nav-3) is showing, clicking the right arrow should transition to slide 4 (car1-radio-4) -->
<label for="car1-radio-4" class="car-rtn car-nav-3"></label>
<!--When slide 4 (car-nav-4) is showing, clicking the left arrow should transition to slide 3 (car1-radio-3) -->
<label for="car1-radio-3" class="car-ltn car-nav-4"></label>
<!--When slide 4 (car-nav-4) is showing, clicking the right arrow should transition to slide 1 (car1-radio-1) -->
<label for="car1-radio-1" class="car-rtn car-nav-4"></label>
</div>
</div>
<div class="car-thumbnails" style="display:none;">
<!-- Thumbnail 1 -->
<label for="car1-radio-1" class="car-thumb car-thumb-1"><div valign="middle" style="font-family:'Open Sans', Arial, Helvetica, sans-serif;font-size:20px;font-weight:700;vertical-align:middle;width:100%;height:auto;line-height:75px;color:#ffffff;margin:0px;"><span>red</span></div></label>
<!-- Thumbnail 2 -->
<label for="car1-radio-2" class="car-thumb car-thumb-2"><div valign="middle" style="font-family:'Open Sans', Arial, Helvetica, sans-serif;font-size:20px;font-weight:700;vertical-align:middle;width:100%;height:auto;line-height:75px;color:#ffffff;margin:0px;"><span>blue</span></div></label>
<!-- Thumbnail 3 -->
<label for="car1-radio-3" class="car-thumb car-thumb-3"><div valign="middle" style="font-family:'Open Sans', Arial, Helvetica, sans-serif;font-size:20px;font-weight:700;vertical-align:middle;width:100%;height:auto;line-height:75px;color:#ffffff;margin:0px;"><span>green</span></div></label>
<label for="car1-radio-4" class="car-thumb car-thumb-4"><div valign="middle" style="font-family:'Open Sans', Arial, Helvetica, sans-serif;font-size:20px;font-weight:700;vertical-align:middle;width:100%;height:auto;line-height:75px;color:#ffffff;margin:0px;"><span>yellow</span></div></label>
</div>
</div>
</td>
</tr>
</table>

z-index does not work with the majority of the email clients.
E:after does not work with the majority of email clients.
webkit-animation is only going to work with IOS, Apple mail.
https://www.campaignmonitor.com/css/positioning-display/z-index/
https://www.campaignmonitor.com/css/selectors/after/
https://www.campaignmonitor.com/css/animations/animation/
Good luck.

I ended up fixing it by making the following changes to the CSS:
.carousel .car-rtn {
z-index: 200;
width: 10%;
}
And I also got rid of the drop shadow on the .carousel .car-ltn::after class.

Related

KeyFrame animation works in Chrome and Edge but not Firefox

Hello I am fairly new to styling and have seen related questions but have not been able to extract my own solution from their answers. I am hoping someone can clue me into why this carousel works as intended on Chrome and Edge but not Firefox. I have tried duplicating nearly all the CSS declarations with -moz prefix without any noticeable impact.
Less importantly, I was only able to animate the nav buttons by targeting their IDs. Originally targeting their class,n-th child had no effect,
This fiddle demonstrates the undesired behavior: https://jsfiddle.net/gharyiey/8h1tLxgo/42/
If you apply color to the "carousel_snapper" div, you can see that it actually is getting animated, but the adjacent div containing the img is not.
Any help is greatly appreciated...
CSS
#keyframes indicate {
0%, 70% {
background-color: #fff;
}
70%, 100% {
background-color: #333;
}
}
#keyframes tonext {
75% {
left: 0%;
}
95% {
left: 100%;
}
98% {
left: 100%;
}
99% {
left: 0%;
}
}
#keyframes tostart {
75% {
left: 0%;
}
95% {
left: -300%;
}
98% {
left: -300%;
}
99% {
left: 0%;
}
}
#keyframes snap {
96% {
scroll-snap-align: center;
}
97% {
scroll-snap-align: none;
}
99% {
scroll-snap-align: none;
}
100% {
scroll-snap-align: center;
}
}
* {
box-sizing: border-box;
scrollbar-color: transparent transparent; /*thumb and track color*/
scrollbar-width: 0px;
}
*::-webkit-scrollbar {
width: 0;
}
*::-webkit-scrollbar-track {
background: transparent;
}
*::-webkit-scrollbar-thumb {
background: transparent;
border: none;
}
.carousel > ol, li {
list-style: none;
margin: 0;
padding: 0;
}
.carousel {
position: relative;
filter: drop-shadow(0 0 10px #0003);
perspective: 100px;
}
.carousel__viewport {
position: relative;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
overflow-x: scroll;
scroll-behavior: smooth;
scroll-snap-type: x mandatory;
}
.carousel__slide {
position: relative;
flex: 0 0 100%;
}
.carousel__slide::before {
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%, -40%, 70px);
color: #fff;
font-size: 2em;
}
.carousel__snapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
scroll-snap-align: center;
/*background-color: greenyellow; <-- UNCOMMENT TO SEE ANIMATED DIV*/
}
#media (hover: hover) {
.carousel__snapper {
animation-name: snap, tonext;
animation-timing-function: ease;
animation-duration: 4100ms;
animation-iteration-count: infinite;
}
#nav1 {
animation: indicate 12300ms infinite -1000ms;
}
#nav2 {
animation: indicate 12300ms infinite 3100ms;
}
#nav3 {
animation: indicate 12300ms infinite 7200ms;
}
.carousel__slide:last-child .carousel__snapper {
animation-name: tostart, snap;
}
}
.carousel:hover .carousel__snapper,
.carousel:focus-within .carousel__snapper {
animation-play-state: paused;
}
.carousel:hover #nav1,
.carousel:focus-within #nav1 {
animation-play-state: paused;
}
.carousel:hover #nav2,
.carousel:focus-within #nav2 {
animation-play-state: paused;
}
.carousel:hover #nav3,
.carousel:focus-within #nav3 {
animation-play-state: paused;
}
.carousel__navigation {
position: absolute;
right: 0;
bottom: 0;
left: 0;
text-align: center;
}
.carousel__navigation-list,
.carousel__navigation-item {
display: inline-block;
}
.carousel__navigation-button {
display: inline-block;
width: 1.5rem;
height: 1.5rem;
background-color: #333;
background-clip: content-box;
border: 0.25rem solid transparent;
border-radius: 50%;
font-size: 0;
transition: transform 0.1s;
}
.dummy_img {
height:290px;
width:640px;
display: block;
margin-left: auto;
margin-right: auto;
}
.img_text {
text-align: center;
vertical-align: middle;
line-height: 290px;
}
HTML
<h1 style="text-align:center">PURE CSS/HTML CAROUSEL WITH ANIMATED NAV</h1>
<section class="carousel" aria-label="Gallery">
<ol class="carousel__viewport">
<li id="carousel__slide1" tabindex="0" class="carousel__slide">
<div class="carousel__snapper"></div>
<div class="dummy_img">
<h1 class="img_text">IMAGE 1</h1>
<!--<a href="">
<img src="img1.jpg" alt="alt_tag_1">
</a>-->
</div>
</li>
<li id="carousel__slide2" tabindex="0" class="carousel__slide">
<div class="carousel__snapper"></div>
<div class="dummy_img">
<h1 class="img_text">IMAGE 2</h1>
<!--<a href="">
<img src="img2.jpg" alt="alt_tag_2">
</a>-->
</div>
</li>
<li id="carousel__slide3" tabindex="0" class="carousel__slide">
<div class="carousel__snapper"></div>
<div class="dummy_img">
<h1 class="img_text">IMAGE 3</h1>
<!--<a href="">
<img src="img3.jpg" alt="alt_tag_3">
</a>-->
</div>
</li>
</ol>
<aside class="carousel__navigation">
<ol class="carousel__navigation-list">
<li class="carousel__navigation-item">
Go to slide 1
</li>
<li class="carousel__navigation-item">
Go to slide 2
</li>
<li class="carousel__navigation-item">
Go to slide 3
</li>
</ol>
</aside>
</section>

how do i make a button fade in with css keyframes?

I'm trying to make my button fade in with keyframes but it isn't working and I know I'm doing something wrong. I ended up getting the animated text to work but this is giving me a headache and I cannot find info anywhere that has helped me... I'm new to web development so don't be too harsh on me or my (probably ugly and unorganized) code lol. I'm trying to learn as much as I can, so if you can please explain why it isn't working and why something else might? Thanks guys <3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght#300&display=swap" rel="stylesheet">
<title>Welcome! | Video Editing by Scottis</title>
</head>
<body>
<!-- Header -->
<div class="container">
<span class="text1">Video Editing by Scottis</span>
</div>
<!-- Buttons -->
<style>
.btn {
background-color: white;
color: rgb(133, 4, 255);
text-align: center;
font-size: 15px;
font-weight: bold;
margin-right: -250px;
margin-top: 600px;
margin-left: 515px;
padding: 30px;
}
</style>
</head>
<body>
<button class="btn">Portfolio</button>
<button class = "btn">Pricing</button>
<button class="btn">Contact</button>
</body>
</html>
My CSS:
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
}
body {
background-image: url("./assets/background.png");
background-color: #cccccc;
background-repeat: no-repeat;
}
/* Create three equal columns that floats next to each other */
.col-md-3 {
float: left;
width: 15%;
padding: 15px;
padding: 10px;
margin: auto;
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width:768px) {
.col-md-3 {
width: 100% auto;
}
}
.col-md-12 {
text-align: center;
}
.card-title {
text-align: center;
}
.container{
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
.container span{
color: white;
text-transform: uppercase;
display: block;
}
.text1{
color: white;
font-size: 60px;
font-weight: 700;
letter-spacing: 8px;
margin-bottom: 20px;
position: relative;
animation: text 3s 1;
}
#keyframes text {
0%{
margin-bottom: -20%;
}
30%{
letter-spacing: 25px;
margin-bottom: -40px;
}
85%{
letter-spacing: 15px;
margin-bottom: -40px;
}
}
}
#keyframes button {
0%{
opacity: 0%;
}
0%{
opacity: 0%;
}
25%{
opacity: 25%;
}
50%{
opacity: 50%;
}
75%{
opacity: 75%;
}
100%{
opacity: 100%;
}
}
You have some issues with your code first off. You are repeating both the head and body tags out of proper valid html sequence. Have a close look at the following page and resource from MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
As to your issue with keyframes, define the class you wish to control with the sequence in your css and add the animation with a unique call name, I used fadeIn. Below I have added Mozilla, webkit, opera and ms #keyframe animations for opacity. I am defining the animation to start the timer (3 seconds) #keyframe 0% { opacity: 0; } , then end at 100% { opacity: 1; }. I add multiple kits for different browsers.
.btn {
animation: fadeIn ease 3s;
-webkit-animation: fadeIn ease 3s;
-moz-animation: fadeIn ease 3s;
-o-animation: fadeIn ease 3s;
-ms-animation: fadeIn ease 3s;
}
#keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-moz-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-o-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
}
body {
background-image: url("./assets/background.png");
background-color: #cccccc;
background-repeat: no-repeat;
}
/* Start class for buttons animation fadeIn ease */
.btn {
animation: fadeIn ease 3s;
-webkit-animation: fadeIn ease 3s;
-moz-animation: fadeIn ease 3s;
-o-animation: fadeIn ease 3s;
-ms-animation: fadeIn ease 3s;
}
#keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-moz-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-o-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-ms-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
/* End of animation keyframes */
/* Create three equal columns that floats next to each other */
.col-md-3 {
float: left;
width: 15%;
padding: 15px;
padding: 10px;
margin: auto;
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width:768px) {
.col-md-3 {
width: 100% auto;
}
}
.col-md-12 {
text-align: center;
}
.card-title {
text-align: center;
}
.container {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
.container span {
color: white;
text-transform: uppercase;
display: block;
}
.text1 {
color: white;
font-size: 60px;
font-weight: 700;
letter-spacing: 8px;
margin-bottom: 20px;
position: relative;
animation: text 3s 1;
}
#keyframes text {
0% {
margin-bottom: -20%;
}
30% {
letter-spacing: 25px;
margin-bottom: -40px;
}
85% {
letter-spacing: 15px;
margin-bottom: -40px;
}
}
}
<div class="container">
<span class="text1">Video Editing by Scottis</span>
</div>
<button class="btn">Portfolio</button>
<button class="btn">Pricing</button>
<button class="btn">Contact</button>

Mouse over on button, another div or HTML tag will side out to the left of the button

Hi I have a problem trying to getting the animation at the left hand side of the button when user mouse over the button. One of the example that explain as below:
HTML:
<div class="block">
<div class="normal">
<span>Follow me...</span>
</div>
<a target="_BLANK" class="hover" href="http://twitter.com/benoitboucart" title="My twitter profile">
on Twitter
</a>
CSS:
/**
* CSS3 balancing hover effect
* Read the tutorial here: http://webbb.be/blog/little-css3-3d-hover-effects/
*/
body {background: #f06;background: linear-gradient(45deg, #f06, yellow);min-height: 100%;}
.block {
width: 150px; color: #fff; margin: 30px auto; text-transform: uppercase; text-align: center; font-family: Helvetica;
position: relative;
perspective: 350;
}
.block .normal {
background: gray; padding: 15px; cursor: pointer;
position:relative; z-index:2;
}
.block .hover {
background: #00aced; margin-top:-48px; padding: 15px; display: block; color: #fff; text-decoration: none;
position: relative; z-index:1;
transition: all 250ms ease;
}
.block:hover .normal {
background: #0084b4;
}
.block:hover .hover {
margin-right: 0;
transform-origin: top;
/*
animation-name: balance;
animation-duration: 1.5s;
animation-timing-function: ease-in-out;
animation-delay: 110ms;
animation-iteration-count: 1;
animation-direction: alternate;
*/
animation: balance 1.5s ease-in-out 110ms 1 alternate;
}
#keyframes balance {
0% { margin-top: 0; }
15% { margin-top: 0; transform: rotateX(-50deg); }
30% { margin-top: 0; transform: rotateX(50deg); }
45% { margin-top: 0; transform: rotateX(-30deg); }
60% { margin-top: 0; transform: rotateX(30deg); }
75% { margin-top: 0; transform: rotateX(-30deg); }
100% { margin-top: 0; transform: rotateX(0deg);}
}
https://jsfiddle.net/9dwk8vzg/
Original link:http://dabblet.com/gist/5559193
But for this example is at the bottom instated of at the left hand side of the button, I tried using margin-right and padding-left still unable to get the mouse over appeal div tag to be on the right hand side, may I know what do I miss to get the div tag to appeal on the right hand side/
/**
* CSS3 balancing hover effect
* Read the tutorial here: http://webbb.be/blog/little-css3-3d-hover-effects/
*/
body {background: #f06;background: linear-gradient(45deg, #f06, yellow);min-height: 100%;}
.block {
width: 150px; color: #fff; margin: 30px auto; text-transform: uppercase; text-align: center; font-family: Helvetica;
position: relative;
perspective: 350;
}
.block .normal {
width: 100%;
background: gray; padding: 15px; cursor: pointer;
position:relative; z-index:2;
}
.block .hover {
width: 100%;
background: #00aced;
padding: 15px;
display: block;
position:absolute;
color: #fff;
text-decoration: none;
z-index:1;
transition: all 250ms ease;
right: -30px;
top: 0;
}
.block:hover .normal {
background: #0084b4;
}
.block:hover .hover {
right: 100%;
transform-origin: top;
/*
animation-name: balance;
animation-duration: 1.5s;
animation-timing-function: ease-in-out;
animation-delay: 110ms;
animation-iteration-count: 1;
animation-direction: alternate;
*/
animation: balance 1.5s ease-in-out 110ms 1 alternate;
}
#keyframes balance {
15% { width: 95%; }
30% { width: 105%; }
45% { width: 97%; }
60% { width: 103%; }
75% { width: 97%; }
100% { width: 100%; }
}
<div class="block">
<div class="normal">
<span>Follow me...</span>
</div>
<a target="_BLANK" class="hover" href="http://twitter.com/benoitboucart" title="My twitter profile">
on Twitter
</a>
</div>

Place one div under another div in this code sample [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am playing around with this code on codepen and I am trying to place text, under the animated circle and centered in the viewport, but I cannot seem to find a way to do it. I have set background: yellow; on the text for visibility.
If you know why the solution works, it would be immensely helpful if you could explain it here for me to understand/learn.
Try this: https://codepen.io/Lansana/pen/ezvVYR
HTML:
<div class="spinner-wrapper">
<div class='spinner'>
<div class='quadrant'></div>
<div class='quadrant'></div>
<div class='quadrant'></div>
<div class='quadrant'></div>
</div>
<div class='text'>test</div>
</div>
CSS:
html,
body {
height: 90%;
}
body {
background: #c2c2c2;
display: flex;
align-items: center;
justify-content: center;
}
.text {
background: yellow;
text-align: center;
}
.spinner-wrapper {
width: auto;
height: auto;
position: relative;
}
.spinner {
width: 300px;
height: 300px;
min-width: 300px;
position: relative;
animation: spin 60s linear infinite;
//border-radius: 300px;
.quadrant {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
//z-index: 10;
mix-blend-mode: multiply;
//opacity: .5;
&:after {
content: "";
color: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 100%;
}
&:nth-child(1) {
animation: slide_horiz_neg 12s linear alternate infinite;
&:after {
//mix-blend-mode: multiply;
//opacity: .5;
background: cyan;
}
}
&:nth-child(2) {
animation: slide_vert_neg 8s linear alternate infinite;
&:after {
//mix-blend-mode: multiply;
//opacity: .5;
background: yellow;
}
}
&:nth-child(3) {
animation: slide_horiz_pos 10s linear alternate infinite;
&:after {
//mix-blend-mode: multiply;
//opacity: .5;
background: magenta;
}
}
/* &:nth-child(4) {
// animation: slide_vert_pos 3.5s linear alternate infinite;
&:after {
mix-blend-mode: normal;
//opacity: .5;
background: #000000;
}
} */
}
}
#keyframes spin {
to {
transform: rotate(360deg);
}
}
#keyframes slide_vert_pos {
0% {
transform: translateY(0%);
}
100% {
transform: translateY(1%);
}
}
#keyframes slide_vert_neg {
0% {
transform: translateY(0%);
}
100% {
transform: translateY(-1%);
}
}
#keyframes slide_horiz_pos {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(1%);
}
}
#keyframes slide_horiz_neg {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(-1%);
}
}
I created a wrapper, which contains your spinner and the text.
The wrapper has an auto height/width, based on it's child elements.
The text can be positioned any way you want within that wrapper, and it is not effected at all by the spinner except for the order in which the two are placed within the dom.
if you use flex, then apply it on HTML so body can shrink on content. margin-left:-50%; will be efficient and can be used to center one element.
For vertical-align, you may use (either) display : inline-block/inline-table + vertical-align:middle in order to center 2 elements being side by sides.
basicly, your CSS template can become
html {
height: 90%;
background: #c2c2c2;
display: flex;
align-items: center;
justify-content: center;
}
body {margin:0;}
.text {
background: yellow;
display: inline-table;/* or inline-block to vertical align */
vertical-align: middle;
margin-left: -50%;/* body flex-child takes width of content, not window ;) */
position: relative;/* bring it up front , add z-index too if needed */
}
.spinner {
display: inline-block;/* not a flex-child anymore & float doesn't allow vertical-align */
vertical-align: middle;/* says itself */
width: 300px;
height: 300px;
min-width: 300px;
position: relative;
animation: spin 60s linear infinite;
}
... and render -> https://codepen.io/anon/pen/qNrxPQ
Modified your code you can have look at codepen
https://codepen.io/anon/pen/KMWZOM
HTML
<div class="wrapper">
<div class='spinner'>
<div class='quadrant'></div>
<div class='quadrant'></div>
<div class='quadrant'></div>
<div class='quadrant'></div>
</div>
<div class='text'>test</div>
</div>
CSS
html,
body {
height: 90%;
}
.wrapper{
position:relative;
margin:0 auto;
}
body {
background: #c2c2c2;
display: flex;
align-items: center;
justify-content: center;
}
.text {
position: absolute;
background: yellow;
top:50%;
left:50%;
}
.spinner {
width: 300px;
height: 300px;
min-width: 300px;
position: relative;
animation: spin 60s linear infinite;
//border-radius: 300px;
.quadrant {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
//z-index: 10;
mix-blend-mode: multiply;
//opacity: .5;
&:after {
content: "";
color: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 100%;
}
&:nth-child(1) {
animation: slide_horiz_neg 12s linear alternate infinite;
&:after {
//mix-blend-mode: multiply;
//opacity: .5;
background: cyan;
}
}
&:nth-child(2) {
animation: slide_vert_neg 8s linear alternate infinite;
&:after {
//mix-blend-mode: multiply;
//opacity: .5;
background: yellow;
}
}
&:nth-child(3) {
animation: slide_horiz_pos 10s linear alternate infinite;
&:after {
//mix-blend-mode: multiply;
//opacity: .5;
background: magenta;
}
}
/* &:nth-child(4) {
// animation: slide_vert_pos 3.5s linear alternate infinite;
&:after {
mix-blend-mode: normal;
//opacity: .5;
background: #000000;
}
} */
}
}
#keyframes spin {
to {
transform: rotate(360deg);
}
}
#keyframes slide_vert_pos {
0% {
transform: translateY(0%);
}
100% {
transform: translateY(1%);
}
}
#keyframes slide_vert_neg {
0% {
transform: translateY(0%);
}
100% {
transform: translateY(-1%);
}
}
#keyframes slide_horiz_pos {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(1%);
}
}
#keyframes slide_horiz_neg {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(-1%);
}
}
You can also try this:
.text {
position: relative;
background: yellow;
right: 150px;
top: 200px;
}
Since your spinner's circumference was 300px, to center it directly below, I divided it by half and assigned that position to the text to center it as well as any number above 150px in order to settle below the circle. Remember, these positions act inverted. Right moves it left and so on.

vertical alignment of text in span - text outside span

I need to have span with text aligned in the center.
Previously I have used line-height for this purpose, but in this case the text for some items are longer and this doesn't work any more.
JSFiddle: http://jsfiddle.net/4jSdu/
HTML:
<ul>
<li><a><span>Short</span></a>
</li>
<li><a><span>Why Should I Monitor?</span></a>
</li>
</ul>
CSS:
ul {
position: relative;
overflow: hidden;
}
span {
background-color: rgba(216, 25, 11, 0.75);
display: block;
height: 70px;
line-height: 70px;
width: 135px;
color: black;
text-align: center;
/*margin: auto 0;*/
font-weight: bold;
font-size: 15px;
position: absolute;
bottom: 14px;
}
li, a {
width: 135px;
height: 100px;
display: inline-block;
}
EDIT:
I want to note that span element has value bottom: 14px. THere is also animate effect on this span. when page loads span has value bottom: -70px (container has overlfow: hidden,s o this span is not seen) and then it appears (using .animate) and goes to bottom: 14px. So the sollution should consider this.
I cannot get this animate effect working in jsfiddle (http://jsfiddle.net/pr5cL/), but it works on my page that is locally created.
$("ul li:not(.img_active)").mouseenter(function() {
$(this).find("span").css("bottom","-55px");
$(this).find("span").animate({bottom:15},500);
}).mouseleave(function(){
$(this).find("span").animate({bottom:-70},500);
});
Here is link: http://www.sheerdigitaltest.net/janus/
Something like this maybe?
span {
display: inline-block;
line-height:1.25;
vertical-align:middle;
width: 135px;
color: black;
text-align: center;
font-weight: bold;
font-size: 15px;
}
a {
background-color: rgba(216, 25, 11, 0.75);
height: 70px;
line-height: 70px;
font-size:0;
overflow:hidden;
}
li, a {
width: 135px;
display: inline-block;
vertical-align:top;
}
span {
-webkit-animation: slidein 2s ; /* Safari 4+ */
-moz-animation: slidein 2s ; /* Fx 5+ */
-o-animation: slidein 2s ; /* Opera 12+ */
animation: slidein 2s ; /* IE 10+ */
}
#-webkit-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#-moz-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#-o-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
Jsfiddle
No IE7 or earlier support. Animation support as per comments.