I have a following div
<div>Circle</div>
I applied styles to the circle using the nth-child, the circle and the text inside it are supposed to spin. In the beginning, when I created the circle, I used
display:table-cell;
property to position the text in the center of the circle. When I run my page in Chrome, all the styles including the positioning look perfect. However, when I ran my code in Mozilla Firefox, I noticed that the positioning left and top don't work when I have display:table-cell; property set. They only work if I remove the display. However, if I remove the display, then my text is messy. In that case I decided to create a pseudo div. I managed to position the text in the the center of the circle, however, when I refresh the page, the spinning circle pushes to the right and the text doesn't spin. How can I fix this problem?
style.css
div:nth-child(3) {
width: 150px;
height: 150px;
background: -webkit-linear-gradient(#006600, #009900, #006600);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#006600, #009900, #006600);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#006600, #009900, #006600);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#006600, #009900, #006600);
/* Standard syntax */
-moz-border-radius: 150px;
-webkit-border-radius: 150px;
border-radius: 150px;
text-align: center;
vertical-align: middle;
position: relative;
display:table-cell;
top: 5%;
left: 75px !important;
color: #F0F0F0;
font-size: 25px;
-webkit-animation-name: spin;
-webkit-animation-duration: 500ms;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-moz-animation-name: spin;
-moz-animation-duration: 500ms;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: linear;
-ms-animation-name: spin;
-ms-animation-duration: 500ms;
-ms-animation-iteration-count: 1;
-ms-animation-timing-function: linear;
animation-name: spin;
animation-duration: 500ms;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#-ms-keyframes spin {
from {
-ms-transform: rotate(0deg);
}
to {
-ms-transform: rotate(360deg);
}
}
#-moz-keyframes spin {
from {
-moz-transform: rotate(0deg);
}
to {
-moz-transform: rotate(360deg);
}
}
#-webkit-keyframes spin {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
#keyframes spin {
from {
transform:rotate(0deg);
}
to {
transform:rotate(360deg);
}
}
The following code is when I made a pseudo div, I did not include the css for spinning since it is the same as in the code above. The circle spins, but for that second that it spins it does to the right and then comes back. The text doesn't spin.
div:nth-child(3){
text-align:center;
position:relative;
width: 150px;
top: 50%;
left: 75%;
color: #F0F0F0;
font-size: 20px;
}
div:nth-child(3):after {
content: '';
width: 150px;
height: 150px;
position: absolute;
bottom: -80%;
left: 50%;
transform: translateX(-50%);
z-index: -1;
background: -webkit-linear-gradient(#006600, #009900, #006600);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#006600, #009900, #006600);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#006600, #009900, #006600);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#006600, #009900, #006600);
/* Standard syntax */
-moz-border-radius: 150px;
-webkit-border-radius: 150px;
border-radius: 150px;
}
jsFiddle : http://jsfiddle.net/jLwmknk1/
Try applying this:
display: table;
table-layout: fixed;
instead of display:table-cell;
Related
I would like to add an animated message banner to a website. It works as expected on desktop and tablet view, however, when I go to a certain width in mobile view (roughly 570px), It doesn't display the full message. It takes away the last word of the sentence. The display message should say "Your reality is a matter of your perception". The word perception is being removed.
.animated-message-container {
height: 60px;
background-color:#339a9a;
border-top: 1px solid #000;
}/*Makes changes to position of the text within the purple bar underneath the contact form*/
.animated-message-text {
height: 50px;
overflow: hidden;
position: relative;
}
.animated-message-text h3 {
font-size: 27px;
color: #fff;
position: absolute;
font-family: 'DM Sans', sans-serif;
width: 100%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: center;
padding: 0.17%;
/* Starting position */
-moz-transform:translateX(100%);
-webkit-transform:translateX(100%);
transform:translateX(100%);
/* Apply animation to this element */
-moz-animation: example1 20s linear infinite;
-webkit-animation: example1 20s linear infinite;
animation: example1 20s linear infinite;
}
/* Move it (define the animation) */
#-moz-keyframes example1 {
0% { -moz-transform: translateX(100%); }
100% { -moz-transform: translateX(-100%); }
}
#-webkit-keyframes example1 {
0% { -webkit-transform: translateX(100%); }
100% { -webkit-transform: translateX(-100%); }
}
#keyframes example1 {
0% {
-moz-transform: translateX(100%); /* Firefox bug fix */
-webkit-transform: translateX(100%); /* Firefox bug fix */
transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%); /* Firefox bug fix */
-webkit-transform: translateX(-100%); /* Firefox bug fix */
transform: translateX(-100%);
}
}
<div class="animated-message-container">
<div class="animated-message-text">
<h3>"Your reality is a matter of your perception"</h3>
</div>
<!--<p>Get in touch to discuss session availability.</p>-->
</div>
Does anyone know a way to resolve this issue?
Thanks in advance.
Your h3 text is getting wrapped.
Add css
white-space : nowrap;
to prevent this. In this example, I've added it to the h3's css.
.animated-message-container {
height: 60px;
background-color:#339a9a;
border-top: 1px solid #000;
}/*Makes changes to position of the text within the purple bar underneath the contact form*/
.animated-message-text {
height: 50px;
overflow: hidden;
position: relative;
}
.animated-message-text h3 {
white-space: nowrap;
font-size: 27px;
color: #fff;
position: absolute;
font-family: 'DM Sans', sans-serif;
width: 100%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: center;
padding: 0.17%;
/* Starting position */
-moz-transform:translateX(100%);
-webkit-transform:translateX(100%);
transform:translateX(100%);
/* Apply animation to this element */
-moz-animation: example1 20s linear infinite;
-webkit-animation: example1 20s linear infinite;
animation: example1 20s linear infinite;
}
/* Move it (define the animation) */
#-moz-keyframes example1 {
0% { -moz-transform: translateX(100%); }
100% { -moz-transform: translateX(-100%); }
}
#-webkit-keyframes example1 {
0% { -webkit-transform: translateX(100%); }
100% { -webkit-transform: translateX(-100%); }
}
#keyframes example1 {
0% {
-moz-transform: translateX(100%); /* Firefox bug fix */
-webkit-transform: translateX(100%); /* Firefox bug fix */
transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%); /* Firefox bug fix */
-webkit-transform: translateX(-100%); /* Firefox bug fix */
transform: translateX(-100%);
}
}
<div class="animated-message-container">
<div class="animated-message-text">
<h3>"Your reality is a matter of your perception"</h3>
</div>
<!--<p>Get in touch to discuss session availability.</p>-->
</div>
I am confused why the after selector is moving faster than the no selector div, can anyone explain why this is the case? The before and after selectors are working perfectly but I cannot seem to edit the actual main div I have the selectors off of. I am kinda new at this and apologize for poor formatting or anything of that sort, But I would greatly appreciate some help on this! I want the inner cicle to move the fastest, the middle to move slower, and the outer the slowest.
https://jsfiddle.net/wnmsfudo/1/
html,
body {
height: 100vh;
width: 100vw;
}
.loader {
margin-top: -80px;
content: "";
display: block;
position: absolute;
top: 50vh;
left: 46vw;
width: 100px;
height: 100px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: red;
animation: spin 2s linear infinite;
}
.loader::before {
content: "";
display: block;
position: absolute;
top: 12.5px;
left: 12.5px;
width: 75px;
height: 75px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: green;
animation: spin 1s linear infinite;
}
.loader::after {
content: "";
display: block;
position: absolute;
top: -12.5px;
left: -12.5px;
width: 125px;
height: 125px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: blue;
animation: spin 3s linear infinite;
}
#keyframes spin {
0% {
-webkit-transform: rotate(0deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(0deg);
/* IE 9 */
transform: rotate(0deg);
/* Firefox 16+, IE 10+, Opera */
}
100% {
-webkit-transform: rotate(360deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(360deg);
/* IE 9 */
transform: rotate(360deg);
/* Firefox 16+, IE 10+, Opera */
}
}
<div class="container">
<div class="loader"></div>
</div>
The issue is that the entire .loader div rotates once every 2 seconds, and that the ::before and ::after pseudo elements therefore rotate with it. Their own rotation is added to the parent's!
So the solution is to adapt the pseudo-elements' rotations so that they move relatively to the main element. The ::after even needs to rotate in reverse if you want to make it appear slower.
html, body {
height: calc(100% - 16px);
}
.loader {
margin-top: -80px;
content: "";
display: block;
position: absolute;
top: 50vh;
left: 46vw;
width: 100px;
height: 100px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: red;
animation: spin 2s linear infinite;
}
.loader::before {
content: "";
display: block;
position: absolute;
top: 12.5px;
left: 12.5px;
width: 75px;
height: 75px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: green;
animation: spin 5s linear infinite;
}
.loader::after {
content: "";
display: block;
position: absolute;
top: -12.5px;
left: -12.5px;
width: 125px;
height: 125px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: blue;
animation: spin 5s linear reverse infinite;
}
#keyframes spin {
0% {
-webkit-transform: rotate(0deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(0deg);
/* IE 9 */
transform: rotate(0deg);
/* Firefox 16+, IE 10+, Opera */
}
100% {
-webkit-transform: rotate(360deg);
/* Chrome, Opera 15+, Safari 3.1+ */
-ms-transform: rotate(360deg);
/* IE 9 */
transform: rotate(360deg);
/* Firefox 16+, IE 10+, Opera */
}
}
<div class="container">
<div class="loader">
</div>
</div>
Two questions:
I found a pretty cool font animation on Codepen, but lost the link for it. I have been looking for it online for the past hour and with no luck!
But anyways, there is a issue with this code. Firefox won't give me the results I want. I have tried adding -moz- to most of the code, but the same background image appears like in the picture I have below.
Is this just not possible with Firefox?
My second question is: I wanted the font to change text with a kind of fade in effect when you hover over a button. I managed that but the animation on the hover text does not move. I am guessing this is because there are two animations attached to the div; is there a way around this?
How can I fix these issues? Thanks for your time.
.font{
position:fixed;
width: 100%;
left: 5%;
top: 5%;
}
.font:before{
position:absolute;
content:"TEST";
top: -10px;
font: 700 5em/1 "Orbitron", sans-serif;
letter-spacing: 0;
padding:.25em 0.325em;
display: block;
margin: 0 auto;
text-shadow: 0 0 80px rgba (255,255,255,.5);
background: url(https://media.24ways.org/2008/02/pattern-howto01.gif) repeat-y;
-moz-background-clip: text;
-moz-text-fill-color: transparent;
-moz-animation: aitf 10s linear infinite;
-moz-transform: translate3d(0,0,0);
-moz-backface-visibility: hidden;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: aitf 10s linear infinite;
-webkit-transform: translate3d(0,0,0);
-webkit-backface-visibility: hidden;
}
#keyframes aitf {
0% { background-position: 0% 50%; }
100% { background-position: 100% 50%; }
}
#-webkit-keyframes aitf {
0% { background-position: 0% 50%; }
100% { background-position: 100% 50%; }
}
#-moz-keyframes aitf {
0% { background-position: 0% 50%; }
100% { background-position: 100% 50%; }
}
.icon {
position: relative;
width: 50px;
height: 50px;
top: 150px;
border-radius: 50%;
border: solid 5px black;
cursor: pointer;
font-size: 30px;
text-align: center;
vertical-align: middle;
line-height: 50px;
margin: 0 0.8%;
background: #730A0C;
}
.icon:hover ~ .font:before{
content:"TEST2";
animation: fadein 2s;
-moz-animation: fadein 2s;
-webkit-animation: fadein 2s;
-o-animation: fadein 2s;
background-position: center;
}
/*Fade Inn Animation*/
#keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-moz-keyframes fadein { /* Firefox */
from {
opacity:0;
}
to {
opacity:1;
}
}
#-webkit-keyframes fadein { /* Safari and Chrome */
from {
opacity:0;
}
to {
opacity:1;
}
}
#-o-keyframes fadein { /* Opera */
from {
opacity:0;
}
to {
opacity: 1;
}
}
/*Fade Inn Animation*/
<div class="icon"> </div>
<div class="font"> </div>
The text-fill-color property is not available in Firefox until Firefox 48 comes out in August of 2016. The only browers that support this property right now are Chrome, Safari, and Opera using the -webkit- prefix.
I am trying to make a page load transition effective div. This is my DEMO FULL PAGE full page from codepen.io and also this is example page with code DEMO WITH CODE
If you open the demo full page then you can see there is a one image and this image opening with transition animation. But there is something went wrong.
When page load the image opening transition but it is opening up to bottom . I want to open it in the middle, without any deviation.
Anyone can help me in this regard ? How can i fixed it ?
This is my CSS code:
.test {
margin: 0px auto;
width: 200px;
height: auto;
margin-top: 50px;
}
.testtransition {
transform: scale(1.2);
width: 200px;
height: 200px;
margin: 0px auto;
margin-top: 50px;
overflow: hidden;
border-radius: 50%;
}
.testtransition img {
width: 100%;
max-width: 200px;
max-height: 200px;
opacity: 1;
-moz-animation: scale 0.8s;
/* Firefox */
-webkit-animation: scale 0.8s;
/* Safari and Chrome */
-o-animation: scale 0.8s;
border-radius: 50%;
-webkit-animation: scale 0.9s;
/* Safari, Chrome and Opera > 12.1 */
-moz-animation: scale 0.9s;
/* Firefox < 16 */
-ms-animation: scale 0.9s;
/* Internet Explorer */
-o-animation: scale 0.9s;
/* Opera < 12.1 */
animation: scale 0.9s;
}
#keyframes scale {
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
#-moz-keyframes scale {
/* Firefox */
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
#-webkit-keyframes scale {
/* Safari and Chrome */
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
#-o-keyframes scale {
/* Opera */
from {
width: 20px;
opacity: 0;
}
to {
width: 200px;
opacity: 1;
}
}
Here's a working pen. A summary of my changes:
Added text-align: center on .testtransition to keep the image centered
Added width, height, and padding to the animation to keep the image centered throughout the animation
Removed the width parameter from the img tag to keep things simple :)
This should do the trick! You need to set a from and to in each animation.
http://codepen.io/anon/pen/GJZvJB
.testtransition {
width: 200px;
height: 200px;
margin: 0px auto;
margin-top: 50px;
overflow: hidden;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
}
.testtransition img {
-webkit-animation: scaleAnim 1s;
-moz-animation: scaleAnim 1s;
-o-animation: scaleAnim 1s;
}
#-webkit-keyframes scaleAnim {
from { -webkit-transform: scale(0) }
to { -webkit-transform: scale(1) }
}
#-moz-keyframes scaleAnim {
from { -moz-transform: scale(0) }
to { -moz-transform: scale(1) }
}
#-o-keyframes scaleAnim {
from { -o-transform: scale(0)}
to { -o-transform: scale(1)}
}
You may have to play with the initial image to maintain an attractive circle, for now i've added backface-visibility.
HTML
<div id="div1">
<div id="div2">HELLO</div>
</div>
<div id="div3">
<div id="div4">HELLO</div>
</div>
CSS
#div1
{
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
-webkit-perspective:150px; /* Chrome, Safari, Opera */
perspective:150px;
}
#div2
{
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
-webkit-transform-origin:0%; /* Chrome, Safari, Opera */
-webkit-transform: rotateY(117deg); /* Chrome, Safari, Opera */
transform: rotateX(-75deg);
}
#div3
{
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
-webkit-perspective:150px; /* Chrome, Safari, Opera */
perspective:150px;
}
#div4
{
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
-webkit-transform-origin:0%; /* Chrome, Safari, Opera */
-webkit-transform: rotateY(0deg); /* Chrome, Safari, Opera */
transform: rotateX(-75deg);
}
Trying to do this rotate the inner div from starting position to final position with a delay 2
Two positions
Code for doing above got it from Here But its not working .What changes to make to make it work
-webkit-backface-visibility: visible;
-webkit-transform-origin: 0% 50%;
-webkit-transform: perspective(800px) rotateY(90deg) rotateY(-90deg);
Here: FIDDLE: http://jsfiddle.net/9dqAK/12/
HTML
<div id="stage">
<div id="spinner">
hello
</div>
</div>
CSS
#-webkit-keyframes spinner {
from {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
}
to {
-webkit-transform: rotateY(-360deg);
-moz-transform: rotateY(-360deg);
}
}
#spinner {
-webkit-transform-origin: 150px 0 0;
-webkit-animation-name: spinner;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 6s;
-webkit-transform-style: preserve-3d;
-moz-transform-origin: 150px 0 0;
-moz-animation-name: spinner;
-moz-animation-timing-function: linear;
-moz-animation-iteration-count: infinite;
-moz-animation-duration: 6s;
-moz-transform-style: preserve-3d;
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
}
#spinner:hover {
-webkit-animation-play-state: paused;
}
You forgot to add when to do the animation. I assume that it is upon let's say hover.
So, add end styles to :hover pseudo-class. And, also specify some transition so that you can see it animating.
Demo: http://jsfiddle.net/abhitalks/WEX75/4/
CSS:
#div1 {
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
-webkit-perspective:150px;
}
#div2 {
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
-webkit-transform-origin:0%;
-webkit-transform: rotateY(117deg);
transition: 1s all;
}
#div1:hover > #div2 {
-webkit-backface-visibility: visible;
-webkit-transform-origin: 50% 50%;
-webkit-transform: perspective(500px) rotateY(0deg);
}
Edit: (After reading Op's comments somewhere above)
You want the animation to happen on page load. So, in that case just apply the relevant CSS using jQuery. Wrap that code in domready.
Demo 2: http://jsfiddle.net/abhitalks/WEX75/3/
JS:
$("#div2").css({
'-webkit-backface-visibility': 'visible',
'-webkit-transform-origin': '50% 50%',
'-webkit-transform': 'perspective(500px) rotateY(0deg)'
});
Edit 2:
You can introduce a delay of 2s by using transition-delay: 2s;.
Demo 3: http://jsfiddle.net/abhitalks/WEX75/5/
Add -webkit- to your last transform CSS declaration