CSS3 Class Inherits Div Opacity in Safari 9.x? - html

W-I-P DEMO (Reduced clutter and added "Correct" and "Incorrect" labels on cube faces for clarity.) An animated CSS cube with 4 autoplay slideshows and animated text (on hover) on each pane works as expected on all 4 cube faces in current versions of FF and Chrome (not yet tested in others), but Safari (both desktop and mobile versions) appear to be overriding the "slidetext" class with the "#keyframes slideshow" opacity (i.e., at 40% of the cube rotation), resulting in opacity-faded text on 2 of the cube faces ~1/2-way through the cube rotation. Where are my coding errors, or could this possibly be a Safari glitch?
HTML
<div id="cubecontainer">
<div class="shadowcontainer">
<div class="shadow">
<div> </div>
</div><!-- end of shadow -->
</div><!-- end of shadowcontainer -->
<div class="cubewrapper">
<div class="cube">
<div class="front"><a href="websites.php">
<div class="slideshowcontainerW">
<img class="slide" src="./images/cube/cubeW1.png" alt="W1" />
<img class="slide" src="./images/cube/cubeW2.png" alt="W2" />
<img class="slide" src="./images/cube/cubeW3.png" alt="W3" />
<img class="slide" src="./images/cube/cubeW4.png" alt="W4" />
</div><span class="slidetext">WEB SITES</span></a>
</div>
<div class="back"><a href="extraordinary.php">
<div class="slideshowcontainerE">
<img class="slide" src="./images/cube/cubeE1.png" alt="E1" />
<img class="slide" src="./images/cube/cubeE2.png" alt="E2" />
<img class="slide" src="./images/cube/cubeE3.png" alt="E3" />
<img class="slide" src="./images/cube/cubeE4.png" alt="E4" />
</div><span class="slidetext">EXTRAORDINARY</span></a>
</div>
<div class="top"> </div>
<div class="bottom"> </div>
<div class="left"><a href="profile.php">
<div class="slideshowcontainerP">
<img class="slide" src="./images/cube/cubeP1.png" alt="P1" />
<img class="slide" src="./images/cube/cubeP2.png" alt="P2" />
<img class="slide" src="./images/cube/cubeP3.png" alt="P3" />
<img class="slide" src="./images/cube/cubeP4.png" alt="P4" />
</div><span class="slidetext">PROFILE</span></a>
</div>
<div class="right"><a href="logos.php">
<div class="slideshowcontainerL">
<img class="slide" src="./images/cube/cubeL1.png" alt="L1" />
<img class="slide" src="./images/cube/cubeL2.png" alt="L2" />
<img class="slide" src="./images/cube/cubeL3.png" alt="L3" />
<img class="slide" src="./images/cube/cubeL4.png" alt="L4" />
</div><span class="slidetext">LOGOS</span></a>
</div>
</div><!-- end of cube -->
</div><!-- end of cubewrapper -->
</div><!-- end of cubecontainer -->
CSS
#cubecontainer {
float:right;
padding-left:50px;
padding-right:50px;
padding-top:10px;
padding-bottom:220px;
}
#cubecontainer:hover div {
animation-play-state: paused;
}
.cubewrapper {
perspective: 800px;
perspective-origin: 50% 100px;
transform-style: preserve-3d;
}
.cube {
position: relative;
width: 200px;
transform-style: preserve-3d;
}
.cube p {
padding: 40px 0;
}
.cube div {
position: absolute;
width: 200px;
height: 200px;
opacity: 0.95;
}
.back {
transform: translateZ(-100px) rotateY(180deg);
background-color: #FFF;
}
.right {
transform: rotateY(-270deg) translateX(100px);
transform-origin: top right;
background-color: #FFF;
}
.left {
transform: rotateY(270deg) translateX(-100px);
transform-origin: center left;
background-color: #FFF;
}
.top {
transform: rotateX(-90deg) translateY(-100px);
transform-origin: top center;
background-color: #FFF;
}
.bottom {
transform: rotateX(90deg) translateY(100px);
transform-origin: bottom center;
background-color: #FFF;
}
.front {
transform: translateZ(100px);
background-color: #FFF;
}
#keyframes cubespin {
from { transform: rotateY(0); }
to { transform: rotateY(-360deg); }
}
.cube, .shadow {
animation: cubespin 16s linear infinite;
}
.shadowcontainer {
perspective: 800px;
perspective-origin: 50% 100px;
}
.shadow {
position: relative;
width: 200px;
transform-style: preserve-3d;
}
.shadow div {
position: absolute;
width: 200px;
height: 200px;
top: 0px;
opacity: 0.98;
box-shadow: 0px 0px 50px 10px #000;
transform: rotateX(90deg) translateY(100px);
transform-origin: bottom center;
}
/*END CUBE*/
/*BEGIN CODE FOR SLIDESHOW ON CUBE FACES*/
.slideshowcontainerE, .slideshowcontainerL, .slideshowcontainerP, .slideshowcontainerW {
margin: 0 auto;
width: 200px;
height: 200px;
overflow: hidden;
position: relative;
}
.slide {
position: absolute;
animation: slideshow 20s infinite;
opacity: 0;
}
.slidetext {
width:195px;
margin: 0px auto;
padding-right:5px;
position: absolute;
text-align: right;
font-size: 1em;
color:#FFF;
text-shadow: 0px 0px 5px #F00;
background:rgba(0,0,0,.75);
border: none;
}
.slidetext:hover {
width:195px;
margin:0px auto;
padding-right:5px;
position: absolute;
text-align: right;
font-size: 1em;
color:#F00;
text-shadow: 0px 0px 5px #FFF;
background:rgba(255,200,100,.75);
border: none;
transition: color, background .5s ease-in;
}
#keyframes slideshow {
25% {
opacity: 1;
}
40% {
opacity: 0;
}
}
img:nth-child(1) {
animation-delay: 15s;
}
img:nth-child(2) {
animation-delay: 10s;
}
img:nth-child(3) {
animation-delay: 5s;
}
img:nth-child(4) {
animation-delay: 0s;
}
/*END CODE FOR SLIDESHOW ON CUBE FACES*/

Related

Should be an infinite scrolling with logos but instead of first image repeating, it starts from beginning

I will be replacing the images for security issues but was wondering what was wrong with the code for it to start from the first image instead of having it repeated after the last image?
And also, I have added the "pause" code in the css but it won't pause. Am I missing another piece of code?
Thanks in advance.
.logo-slider {
background: white;
-webkit-box-shadow: 0 0px 0px 0px rgba(0, 0, 0, 0.125);
box-shadow: 0 0px 0px 0px rgba(0, 0, 0, 0.125);
margin: auto;
overflow: hidden;
position: relative;
width: 1500px;
}
.logo-slider img {
width: auto;
height: 30px;
padding: 0 10px 0 10px;
}
.logo-slider img:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
cursor: pointer;
}
.logo-slider::before,
.logo-slider::after {
background: -webkit-gradient(linear, left top, right top, from(white), to(rgba(255, 255, 255, 0)));
background: linear-gradient(to right, white 0%, rgba(255, 255, 255, 0) 100%);
content: "";
height: 125px;
position: absolute;
width: 200px;
z-index: 2;
}
.logo-slider::after {
right: 0;
top: 0;
-webkit-transform: rotateZ(180deg);
transform: rotateZ(180deg);
}
.logo-slider::before {
left: 0;
top: 0;
}
.logo-slider .logo-slide-track {
-webkit-animation: logo-scroll 60s linear infinite;
animation: logo-scroll 60s linear infinite;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: calc(250px * 14);
animation-duration: 30s;
animation-iteration-count: infinite;
}
.logo-slider .slide {
height: auto;
width: 150px;
padding: 5px;
text-align: center;
}
#-webkit-keyframes logo-scroll {
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(calc(-250px * 7));
transform: translateX(calc(-250px * 7));
}
}
#keyframes logo-scroll {
0% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-webkit-transform: translateX(calc(-250px * 7));
transform: translateX(calc(-250px * 7));
}
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
<title>Thanks Holdings</title>
</head>
<body>
<div class="logo-slider">
<div class="logo-slide-track">
<div class="slide">
<img src="a.png" alt="" />
</div>
<div class="slide">
<img src="b.png" alt="" />
</div>
<div class="slide">
<img src="c.png" alt="" />
</div>
<div class="slide">
<img src="f.png" alt="" />
</div>
<div class="slide">
<img src="e.png" alt="" />
</div>
<div class="slide">
<img src="f.png" alt="" />
</div>
<div class="slide">
<img src="g.png" alt="" />
</div>
<div class="slide">
<img src="h.png" alt="y" />
</div>
<div class="slide">
<img src="i.png" alt="" />
</div>
<div class="slide">
<img src="j.png" alt="" />
</div>
<div class="slide">
<a href="k.png" alt="" />
</div>
<div class="slide">
<a href="l.png" alt="" />
</div>
</div>
</div>
</body>
</html>
The main issue here is that you're attempting to move the entire .slide-track element instead of each .slide element separately. This means that the .slide elements cannot begin repeating until they are all off of the screen, since the animation is applied to the .slide-track. Once they are all off the screen, the animation will begin again where it started, in the center of the screen.
Another issue is that the .slide elements do not begin off of the right side of the screen, so they do not return to that position once the animation is completed. To solve this issue, you can begin the elements off the right side of the screen and use a negative animation-delay property to move them along.
.logo-slider {
background: white;
-webkit-box-shadow: 0 0px 0px 0px rgba(0, 0, 0, 0.125);
box-shadow: 0 0px 0px 0px rgba(0, 0, 0, 0.125);
margin: auto;
overflow: hidden;
position: relative;
width: 1500px;
}
.logo-slider img {
width: auto;
height: 30px;
padding: 0 10px 0 10px;
}
.logo-slider img:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
cursor: pointer;
}
.logo-slider::before,
.logo-slider::after {
background: -webkit-gradient(linear, left top, right top, from(white), to(rgba(255, 255, 255, 0)));
background: linear-gradient(to right, white 0%, rgba(255, 255, 255, 0) 100%);
content: "";
height: 125px;
position: absolute;
width: 200px;
z-index: 2;
}
.logo-slider::after {
right: 0;
top: 0;
-webkit-transform: rotateZ(180deg);
transform: rotateZ(180deg);
}
.logo-slider::before {
left: 0;
top: 0;
}
.logo-slider .logo-slide-track {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: calc(250px * 14);
background-color: yellow; /* TESTING */
}
.logo-slider .slide {
height: auto;
width: 150px;
padding: 5px;
text-align: center;
-webkit-animation: logo-scroll 60s linear infinite;
animation: logo-scroll 60s linear infinite;
animation-duration: 30s;
animation-iteration-count: infinite;
}
.logo-slider .slide:nth-child(1) {
animation-delay: -8s;
}
.logo-slider .slide:nth-child(2) {
animation-delay: -7.5s;
}
.logo-slider .slide:nth-child(3) {
animation-delay: -7s;
}
.logo-slider .slide:nth-child(4) {
animation-delay: -6.5s;
}
.logo-slider .slide:nth-child(5) {
animation-delay: -6s;
}
.logo-slider .slide:nth-child(6) {
animation-delay: -5.5s;
}
.logo-slider .slide:nth-child(7) {
animation-delay: -5s;
}
.logo-slider .slide:nth-child(8) {
animation-delay: -4.5s;
}
.logo-slider .slide:nth-child(9) {
animation-delay: -4s;
}
.logo-slider .slide:nth-child(10) {
animation-delay: -3.5s;
}
.logo-slider .slide:nth-child(11) {
animation-delay: -3s;
}
.logo-slider .slide:nth-child(12) {
animation-delay: -2.5s;
}
#-webkit-keyframes logo-scroll {
0% {
-webkit-transform: translateX(100vw);
transform: translateX(100vw);
}
100% {
-webkit-transform: translateX(calc(-250px * 7));
transform: translateX(calc(-250px * 7));
}
}
#keyframes logo-scroll {
0% {
-webkit-transform: translateX(100vw);
transform: translateX(100vw);
}
100% {
-webkit-transform: translateX(calc(-250px * 7));
transform: translateX(calc(-250px * 7));
}
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
<title>Thanks Holdings</title>
</head>
<body>
<div class="logo-slider">
<div class="logo-slide-track">
<div class="slide">
<img src="a.png" alt="A" />
</div>
<div class="slide">
<img src="b.png" alt="B" />
</div>
<div class="slide">
<img src="c.png" alt="C" />
</div>
<div class="slide">
<img src="d.png" alt="D" />
</div>
<div class="slide">
<img src="e.png" alt="E" />
</div>
<div class="slide">
<img src="f.png" alt="F" />
</div>
<div class="slide">
<img src="g.png" alt="G" />
</div>
<div class="slide">
<img src="h.png" alt="H" />
</div>
<div class="slide">
<img src="i.png" alt="I" />
</div>
<div class="slide">
<img src="j.png" alt="J" />
</div>
<div class="slide">
<img src="k.png" alt="K" />
</div>
<div class="slide">
<img src="l.png" alt="L" />
</div>
</div>
</div>
</body>
</html>
This isn't a perfect example, but it should help to show where the problem lies.
Let me know if you have any questions on how it works.
Your Problem as mentioned before is you're trying to move the whole block of images, and the obvious answer is to move each img on it's own, also another problem is that your animation isn't coded properly to achieve your desired behavior, with little tinkering i managed to get to work as you described, hope it works :)
*,
*:before,
*:after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.logo-slider {
background: white;
-webkit-box-shadow: 0 0px 0px 0px rgba(0, 0, 0, 0.125);
box-shadow: 0 0px 0px 0px rgba(0, 0, 0, 0.125);
margin: auto;
overflow: hidden;
position: relative;
width: 1500px;
}
.logo-slider img {
width: auto;
height: 30px;
padding: 0 10px 0 10px;
}
.logo-slider img:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
cursor: pointer;
}
.logo-slider::before,
.logo-slider::after {
background: -webkit-gradient(linear, left top, right top, from(white), to(rgba(255, 255, 255, 0)));
background: linear-gradient(to right, white 0%, rgba(255, 255, 255, 0) 100%);
content: "";
height: 125px;
position: absolute;
width: 200px;
z-index: 2;
}
.logo-slider::after {
right: 0;
top: 0;
-webkit-transform: rotateZ(180deg);
transform: rotateZ(180deg);
}
.logo-slider::before {
left: 0;
top: 0;
}
.logo-slider .slide {
height: auto;
width: 150px;
padding: 5px;
text-align: center;
animation: logo-scroll 15s linear infinite;
}
.logo-slider .logo-slide-track {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: calc(250px * 14);
animation-duration: 30s;
animation-iteration-count: infinite;
}
#keyframes logo-scroll {
0% {
transform: translateX(calc(250px * 7));
}
100% {
transform: translateX(calc(-250px * 7));
}
}
<div class="logo-slider">
<div class="logo-slide-track">
<div class="slide">
<img src="a.png" alt="A" />
</div>
<div class="slide">
<img src="b.png" alt="B" />
</div>
<div class="slide">
<img src="c.png" alt="C" />
</div>
<div class="slide">
<img src="d.png" alt="D" />
</div>
<div class="slide">
<img src="e.png" alt="E" />
</div>
<div class="slide">
<img src="f.png" alt="F" />
</div>
<div class="slide">
<img src="g.png" alt="G" />
</div>
<div class="slide">
<img src="h.png" alt="H" />
</div>
<div class="slide">
<img src="i.png" alt="I" />
</div>
<div class="slide">
<img src="j.png" alt="J" />
</div>
<div class="slide">
<img src="k.png" alt="K" />
</div>
<div class="slide">
<img src="l.png" alt="L" />
</div>
</div>
</div>
However, it is still not the desired effect, if you want the first img to appear after the last image and so on, this can't be achieved with only css, you'll have to include js maybe some plugin to do it for you.

Adding text next to slideshow images

this is a code I modified it a little bit to make a simple slideshow with images using only HTML and CSS:
(This is a part of the code to see it all please click on demo)
Code:
.slideshow {
width: 800px;
margin: 0 auto;
overflow: hidden;
border: solid 1px white;
}
.slideshow-container {
width: 2500px;
font-size: 0;
transition: 1s ease;
height: 225px;
}
#keyframes slide {
0% {
transform: translateX(0%);
}
12.5% {
transform: translateX(0%);
}
25% {
transform: translateX(-25%);
}
37.5% {
transform: translateX(-25%);
}
50% {
transform: translateX(-50%);
}
62.5% {
transform: translateX(-50%);
}
75% {
transform: translateX(-75%);
}
87.5% {
transform: translateX(-75%);
}
99% {
transform: translateX(-75%);
}
100% {
transform: translateX(0);
}
}
<section class="slideshow">
<div class="slideshow-container slide">
<img src="http://placeimg.com/625/225/any" />
<img src="http://placeimg.com/625/225/animals" />
<img src="http://placeimg.com/625/225/arch" />
</div>
</section>
demo
I want to add a text next to each image, so in the frame I will have half of it image and the other half text.
How can I achieve that?
You will wrap your image and text part into a .item div.
Apply display:flex to parent .slideshow-container to set .item in a row.
Then just apply width:50% to your img and .caption div to align them half of the screen
Also changed your animation animation partition values according to 3 items in a row
Fiddle Link
Stack Snippet
/*general styles*/
body {
padding: 3em;
background-color: #ccc;
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
/*slideshow styles*/
.slideshow {
width: 800px;
margin: 0 auto;
overflow: hidden;
border: solid 1px white;
}
.item {
display: flex;
width: 800px;
align-items: center;
}
.slideshow-container {
width: 2400px;
transition: 1s ease;
display: flex;
}
.slideshow-container:hover {
animation-play-state: paused;
}
.slide {
animation: slide 24s ease infinite;
}
#keyframes slide {
0% {
transform: translateX(0%);
}
25% {
transform: translateX(0);
}
37.5% {
transform: translateX(-33.333%);
}
62.5% {
transform: translateX(-33.333%);
}
75% {
transform: translateX(-66.667%);
}
99% {
transform: translateX(-66.667%);
}
100% {
transform: translateX(0);
}
}
.item img {
width: 50%
}
.item .caption {
width: 50%
}
<!--hovering over the images will pause the slideshow -->
<section class="slideshow">
<div class="slideshow-container slide">
<div class="item">
<img src="http://placeimg.com/625/225/any" />
<div class="caption">Text</div>
</div>
<div class="item">
<img src="http://placeimg.com/625/225/animals" />
<div class="caption">Text</div>
</div>
<div class="item">
<img src="http://placeimg.com/625/225/arch" />
<div class="caption">Text</div>
</div>
</div>
</section>

How do I stack images on top of each other wrapped in the same div, and then have them separate with animation when I hover?

HTML:
<div class="mySlides">
<img src="1.jpg">
<img src="2.jpg"/>
<img src="3.jpg"/>
<img src="4.jpg"/>
<img src="5.jpg"/>
</div>
CSS:
.mySlides {
padding-top: 25%;
padding-left: 5%;
}
.mySlides img {
object-fit: cover;
position: absolute;
max-width: 35%;
}
.mySlides img:nth-of-type(1) {
left: 0%;
top: 0%;
-webkit-transform: rotate(5deg);
-moz-transform: rotate(5deg);
-o-transform: rotate(5deg);
transform: rotate(5deg);
}
This will be repeated for all images, i.e. nth-of-type(2,3,4,5)
.mySlides img {
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
-o-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
padding: 10px 10px 30px 10px;
background: linear-gradient(#ffffff, #eaeaea);
border: solid 1px black;
}
I wanted to stack the images on top of each other and have them all centered on the screen.
On hovering I wanted the images to separate horizontally while still maintaining the animation.
Check this out
Working fiddler https://jsfiddle.net/RaajNadar/L0ennqwp/
Html
<div class="mySlides">
<img src="http://lorempixel.com/400/200/">
<img src="http://lorempixel.com/400/200/sports"/>
</div>
css
.mySlides {
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
max-width: 300px;
transition: left 1.2s ease-in-out;
}
.mySlides:hover img:last-child {
left: 300px;
}
Also got a nice animation.
Is this what you need?
.mySlides {
display: flex;
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
}
.mySlides:hover img {
position: relative;
top: auto;
left: auto;
}
<div class="mySlides">
<img src="http://placehold.it/300x150/000000">
<img src="http://placehold.it/300x150/003300" />
<img src="http://placehold.it/300x150/00ff00" />
<img src="http://placehold.it/300x150/006600" />
<img src="http://placehold.it/300x150/ff0000" />
</div>

Insert text below 5 div with an overlay div inside Css Html

I want to insert a text below the single people's image.
This is my situation:
HTML:
<div class="background">
<div class="layer">
<div class="div-diviso">
<img src="http://77.238.26.244:81/confimi/wp-content/uploads/2017/02/SILVIA-FAIT-2017_980.jpg">
<div class="overlay">
</div>
</div>
<div class="div-diviso">
<img src="http://77.238.26.244:81/confimi/wp-content/uploads/2017/02/CLAUDIO-ZAMPARELLI-2017_980.jpg">
<div class="overlay">
</div>
</div>
<div class="div-diviso">
<img src="http://77.238.26.244:81/confimi/wp-content/uploads/2017/02/ROBERTA-MAGNANI-2017_980.jpg">
<div class="overlay">
</div>
</div>
<div class="div-diviso">
<img src="http://77.238.26.244:81/confimi/wp-content/uploads/2017/02/BARBARA-VANNI-2017_980.jpg">
<div class="overlay">
</div>
</div>
<div class="div-diviso">
<img src="http://77.238.26.244:81/confimi/wp-content/uploads/2017/02/SANDRO-CAMPANI-2017_980.jpg">
<div class="overlay">
</div>
</div>
</dvi>
</div>
CSS:
.background {
background-image: url('http://77.238.26.244:81/confimi/wp-content/uploads/2016/08/a.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
height: 100%;
}
.layer {
background-color: rgba(18, 29, 47, 0.96);
background-repeat: repeat;
width: 100%;
height: 100%;
text-align: center;
padding: 200px 20px 200px 20px;
}
.div-diviso {
width: 17%;
margin: 10px;
display: inline-block;
position: relative;
box-sizing: border-box;
}
.div-diviso img {
width: 100%;
position: relative;
}
.div-diviso .overlay {
width: 100%;
height: 100%;
position: absolute;
box-sizing: border-box;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.6);
opacity: 0;
transform: scale(0.1);
-webkit-transform: scale(0.1);
-moz-transform: scale(0.1);
-ms-transform: scale(0.1);
-o-transform: scale(0.1);
transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
visibility: hidden;
}
.div-diviso:hover .overlay {
opacity: 1;
transform: scale(1);
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
visibility: visible;
border: 3px solid #ffffff;
transform: border 2.75s;
}
#media (min-width: 768px) and (max-width: 980px) {
.layer {
text-align: center;
}
.div-diviso {
width: 47%;
margin: 10px;
}
}
#media (max-width: 767px) {
.layer {
text-align: center;
}
.div-diviso {
width: 98%;
margin: 5px;
}
}
And this is what i want:
I tried to insert a div with the text after this but the over effect covers also the written like this:
Try to add text block after overlay
<div class="div-diviso">
<img src="http://77.238.26.244:81/confimi/wp-content/uploads/2017/02/SANDRO-CAMPANI-2017_980.jpg">
<div class="overlay">
</div>
<div class="text-block">
/*here you text*/
</div>
Just add a div under each div-diviso and wrap in another div :)
.background {
background-image: url('http://77.238.26.244:81/confimi/wp-content/uploads/2016/08/a.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
height: 100%;
}
.layer {
background-color: rgba(18, 29, 47, 0.96);
background-repeat: repeat;
width: 100%;
height: 100%;
text-align: center;
padding: 200px 20px 200px 20px;
}
.div-diviso {
width: 17%;
margin: 10px;
display: inline-block;
position: relative;
box-sizing: border-box;
}
.div-diviso img {
width: 100%;
position: relative;
}
.div-diviso .overlay {
width: 100%;
height: 100%;
position: absolute;
box-sizing: border-box;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.6);
opacity: 0;
transform: scale(0.1);
-webkit-transform: scale(0.1);
-moz-transform: scale(0.1);
-ms-transform: scale(0.1);
-o-transform: scale(0.1);
transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
visibility: hidden;
}
.div-diviso:hover .overlay {
opacity: 1;
transform: scale(1);
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
visibility: visible;
border: 3px solid #ffffff;
transform: border 2.75s;
}
#media (min-width: 768px) and (max-width: 980px) {
.layer {
text-align: center;
}
.div-diviso {
width: 47%;
margin: 10px;
}
}
#media (max-width: 767px) {
.layer {
text-align: center;
}
.div-diviso {
width: 98%;
margin: 5px;
}
.image-description {
width: 100%;
color: white;
text-align:left;
}
.duties-text {
color: blue;
font-size: 16px;
}
}
<div class="background">
<div class="layer">
<div class="div-diviso-container">
<div class="div-diviso">
<img src="http://77.238.26.244:81/confimi/wp-content/uploads/2017/02/SILVIA-FAIT-2017_980.jpg" />
<div class="overlay">
</div>
</div>
<div class="image-description">
<h2>Silvia Feit</h2>
<span class="duties-text"> Responsible for some shinanigans</span>
</div>
</div>
</div>
</div>

Rotate objects around circle using CSS?

I'm attempting to have three objects rotating around a circle. So far I've been able to get one object to spin around the circle. I am unable to get more than one without messing up the code. Could anyone advise on the best way to accomplish this? Here is part of the code and a Fiddle. Thanks!
Here is the Demo
.outCircle {
width: 200px;
height: 200px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
.rotate {
width: 100%;
height: 100%;
-webkit-animation: circle 10s infinite linear;
}
.counterrotate {
width: 50px;
height: 50px;
-webkit-animation: ccircle 10s infinite linear;
}
.inner {
width: 100px;
height: 100px;
background: red;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 100px;
position: absolute;
left: 0px;
top: 0px;
background-color: red;
display: block;
}
#-webkit-keyframes circle {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(360deg)
}
}
#-webkit-keyframes ccircle {
from {
-webkit-transform: rotateZ(360deg)
}
to {
-webkit-transform: rotateZ(0deg)
}
}
<div class="outCircle">
<div class="rotate">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
</div>
Jquery solution which works for any number of outer items.
Jquery shamelessly stolen from ThiefMaster♦ and their answer at this Q & A
var radius = 100; // adjust to move out items in and out
var fields = $('.item'),
container = $('#container'),
width = container.width(),
height = container.height();
var angle = 0,
step = (2 * Math.PI) / fields.length;
fields.each(function() {
var x = Math.round(width / 2 + radius * Math.cos(angle) - $(this).width() / 2);
var y = Math.round(height / 2 + radius * Math.sin(angle) - $(this).height() / 2);
if (window.console) {
console.log($(this).text(), x, y);
}
$(this).css({
left: x + 'px',
top: y + 'px'
});
angle += step;
});
body {
padding: 2em;
}
#container {
width: 200px;
height: 200px;
margin: 10px auto;
border: 1px solid #000;
position: relative;
border-radius: 50%;
animation: spin 10s linear infinite;
}
.item {
width: 30px;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 50%;
position: absolute;
background: #f00;
animation: spin 10s linear infinite reverse;
}
#keyframes spin {
100% {
transform: rotate(1turn);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</div>
How about this, demo at the bottom with 3 circles:
.outCircle {
width: 200px;
height: 200px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
.duringTwentyOne {
-webkit-animation-duration: 21s;
}
.duringTen {
-webkit-animation-duration: 10s;
}
.duringFour {
-webkit-animation-duration: 4s;
}
.infinite {
-webkit-animation-iteration-count: infinite;
}
.linear {
-webkit-animation-timing-function: linear;
}
.counter {
width: 50px;
height: 50px;
-webkit-animation-duration: inherit;
-webkit-animation-direction: reverse;
-webkit-animation-timing-function: inherit;
-webkit-animation-iteration-count: inherit;
-webkit-animation-name: inherit;
}
.rotate {
width: 100%;
height: 100%;
-webkit-animation-name: circle;
position: relative;
z-index : 10;
display : block;
}
.second {
top : -100%;
}
.thirdBigger {
top : -240%;
left: -40%;
width:150%;
height: 150%;
}
.inner {
width: 100px;
height: 100px;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 100px;
position: absolute;
left: 0px;
top: 0px;
background-color: red;
display: block;
}
.red {
background: red;
}
.green {
background: green;
}
#keyframes circle {
from {-webkit-transform: rotateZ(0deg)}
to {-webkit-transform: rotateZ(360deg)}
}
<div class="outCircle">
<div class="rotate linear infinite duringTen">
<div class="counter">
<div class="inner">hello
</div>
</div>
</div>
<div class="second rotate linear infinite duringFour">
<div class="counter">
<div class="inner red">bye bye
</div>
</div>
</div>
<div class="thirdBigger rotate linear infinite duringTwentyOne">
<div class="counter">
<div class="inner green">s'up
</div>
</div>
</div>
</div>
Here is a more generic idea with less of code where you don't need JS and you only need to apply an animation to the item (not the container). The trick is to make all the elements at the same position and using the same animation then with the delay we can have the needed result:
#container {
width: 200px;
height: 200px;
margin: 40px auto;
border: 1px solid #000;
display:grid;
grid-template-columns:30px;
grid-template-rows:30px;
place-content: center;
border-radius: 50%;
}
.item {
grid-area:1/1;
line-height: 30px;
text-align: center;
border-radius: 50%;
background: #f00;
animation: spin 12s var(--d,0s) linear infinite; /* duration = 12s, numbor of item = 6 so a delay of 12/6 = 2s */
transform:rotate(0) translate(100px) rotate(0);
}
#keyframes spin {
100% {
transform:rotate(1turn) translate(100px) rotate(-1turn);
}
}
<div id="container">
<div class="item" style="--d:0s">1</div>
<div class="item" style="--d:-2s">2</div>
<div class="item" style="--d:-4s">3</div>
<div class="item" style="--d:-6s">4</div>
<div class="item" style="--d:-8s">5</div>
<div class="item" style="--d:-10s">6</div>
</div>
We can easily scale to any number using some CSS variables:
#container {
--n:7; /* number of item */
--d:12s; /* duration */
width: 200px;
height: 200px;
margin: 40px auto;
border: 1px solid #000;
display:grid;
grid-template-columns:30px;
grid-template-rows:30px;
place-content: center;
border-radius: 50%;
}
.item {
grid-area:1/1;
line-height: 30px;
text-align: center;
border-radius: 50%;
background: #f00;
animation: spin var(--d) linear infinite;
transform:rotate(0) translate(100px) rotate(0);
}
#keyframes spin {
100% {
transform:rotate(1turn) translate(100px) rotate(-1turn);
}
}
.item:nth-child(1) {animation-delay:calc(-0*var(--d)/var(--n))}
.item:nth-child(2) {animation-delay:calc(-1*var(--d)/var(--n))}
.item:nth-child(3) {animation-delay:calc(-2*var(--d)/var(--n))}
.item:nth-child(4) {animation-delay:calc(-3*var(--d)/var(--n))}
.item:nth-child(5) {animation-delay:calc(-4*var(--d)/var(--n))}
.item:nth-child(6) {animation-delay:calc(-5*var(--d)/var(--n))}
.item:nth-child(7) {animation-delay:calc(-6*var(--d)/var(--n))}
.item:nth-child(8) {animation-delay:calc(-7*var(--d)/var(--n))}
.item:nth-child(9) {animation-delay:calc(-8*var(--d)/var(--n))}
/*.item:nth-child(N) {animation-delay:calc(-(N - 1)*var(--d)/var(--n))}*/
<div id="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
</div>
<div id="container" style="--n:5;--d:5s">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
</div>
<div id="container" style="--n:9">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
Not sure if this is what you are after, but you need to position your rotating circles absolutely (so they don't interfere with each other) and then give them their own animation:
For the counter rotation, just make them then minus of what the rotation degrees is and that will keep your text horizontal
.outCircle {
width: 200px;
height: 200px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
.rotate {
width: 100%;
height: 100%;
position: absolute; /* add this */
}
.counterrotate {
width: 100px;
height: 100px;
}
.inner {
width: 100px;
height: 100px;
text-align: center;
vertical-align: middle;
background: red;
border-radius: 100px;
background-color: red;
display: table-cell;
}
.anim1 {
-webkit-animation: circle1 10s infinite linear;
}
.anim1 .counterrotate {
-webkit-animation: ccircle1 10s infinite linear;
}
.anim2 {
-webkit-animation: circle2 10s infinite linear;
}
.anim2 .counterrotate {
-webkit-animation: ccircle2 10s infinite linear;
}
.anim3 {
-webkit-animation: circle3 10s infinite linear;
}
.anim3 .counterrotate {
-webkit-animation: ccircle3 10s infinite linear;
}
#-webkit-keyframes circle1 {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(360deg)
}
}
#-webkit-keyframes ccircle1 {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(-360deg)
}
}
#-webkit-keyframes circle2 {
from {
-webkit-transform: rotateZ(90deg)
}
to {
-webkit-transform: rotateZ(450deg)
}
}
#-webkit-keyframes ccircle2 {
from {
-webkit-transform: rotateZ(-90deg)
}
to {
-webkit-transform: rotateZ(-450deg)
}
}
#-webkit-keyframes circle3 {
from {
-webkit-transform: rotateZ(180deg)
}
to {
-webkit-transform: rotateZ(540deg)
}
}
#-webkit-keyframes ccircle3 {
from {
-webkit-transform: rotateZ(-180deg)
}
to {
-webkit-transform: rotateZ(-540deg)
}
}
<div class="outCircle">
<div class="rotate anim1">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
<div class="rotate anim2">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
<div class="rotate anim3">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
</div>
Use translateX.
See this jsfiddle.
I made the outer circle position: relative and the inner ones position: absolute, so they lie on top of each others mids (which is just for illustration, this is just for positioning the child circles on the same spot; grouping them).
Then, from this center spot, the translateX tells the animation to give it a radius of in this case 100px (which is the radius of the outer circle).
There you go.
.circleLink {
color: #ececec;
text-transform: uppercase;
font-size: 24px;
line-height: 120%;
position: relative;
display: inline-block;
border: 1px solid blue;
width: 200px;
height: 200px;
-moz-box-flex: 0;
flex: 0 0 270px;
display: -moz-box;
display: flex;
-moz-box-pack: center;
justify-content: center;
-moz-box-align: center;
align-items: center;
border-radius: 50%;
}
.round>span:first-child {
position: relative;
color:blue;
}
.round>span:first-child::before {
content: "";
position: absolute;
width: 100%;
height: 0;
border: 1px solid #ececec;
bottom: -5px;
background: #ececec;
border-radius: 10px;
left: 0;
}
.round>span:nth-child(2) {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
transform: rotate(90deg);
}
.circleLink>span:nth-child(2) {
position: absolute;
z-index: 1;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.circleLink>span:nth-child(2) span {
position: absolute;
top: -webkit-calc(50% - 0.5px);
top: -moz-calc(50% - .5px);
top: calc(50% - 0.5px);
left: 50%;
z-index: 1;
width: 50%;
height: 1px;
-webkit-transform-origin: left;
-moz-transform-origin: left;
transform-origin: left;
-webkit-animation: linkRotate 5s linear 0s infinite;
-moz-animation: linkRotate 5s linear 0s infinite;
animation: linkRotate 5s linear 0s infinite;
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
animation-play-state: paused;
}
.circleLink>span:nth-child(2) span:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
top: -10px;
right: -10px;
background: #42B4EF;
border-radius: 50%;
}
.circleLink:hover>span:nth-child(2) span {
-webkit-animation-play-state: running;
-moz-animation-play-state: running;
animation-play-state: running;
}
#-webkit-keyframes linkRotate {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg)
}
to {
-webkit-transform: rotate(1turn);
transform: rotate(1turn)
}
}
#-moz-keyframes linkRotate {
0% {
-moz-transform: rotate(0deg);
transform: rotate(0deg)
}
to {
-moz-transform: rotate(1turn);
transform: rotate(1turn)
}
}
#keyframes linkRotate {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
transform: rotate(0deg)
}
to {
-webkit-transform: rotate(1turn);
-moz-transform: rotate(1turn);
transform: rotate(1turn)
}
}
<div class="round">
<a href="#" class="circleLink">
<span>Loram</span>
<span><span></span></span>
</a>
</div>