CSS will-change breaks on Safari - html

if I apply the will-change: opacity;property to my element with a fixed value of border radious, this will broke the css and not consider the overflow and the radius.
it just happens on Safari, the other browsers are ok.
.card{
border-radius: 80px;
height: 200px;
width: 200px;
position: relative;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
}
.bg-image{
position: absolute;
width: auto;
height: 100%;
display: block;
z-index: 1;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
will-change: opacity; // => COMMENT HERE and it's works
}
.card--content{
z-index: 30;
position: relative;
top: 40%;
height: 60%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
}
.card::before{
content: '';
display: block;
position: absolute;
bottom: 0;
height: 0;
width: 100%;
background-color: white;
z-index: 20;
will-change: height;
transition: height 0.24s ease-in-out;
}
.card::after{
content: '';
display: block;
position: absolute;
bottom: 0;
height: 100%;
width: 100%;
z-index: 10;
background: linear-gradient(180.49deg, rgba(136, 168, 187, 0.217) 40.63%, rgba(0, 122, 194, 0.7) 71.44%);
opacity: 1;
transition: opacity 0.25s linear;
}
.card:hover::after{
opacity: 0;
}
<div class="card">
<img class="bg-image lazy entered loaded" data-src="https://dummyimage.com/600 x 600/cfcfcf/fff.png" aria-label="" data-ll-status="loaded" src="https://dummyimage.com/600 x 600/cfcfcf/fff.png">
<div class="card--content">
content
</div>
</div>
someone had the same problem?
thanks

Related

Shine effect on button ever 3 seconds (no hover)

I'd like to be able to have the div shine-box go across the image automatically from the top left ever like 3 seconds, left to right, left to right etc.
This is the current code:
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: darkblue;
}
img {
border: 0;
}
.shine-box {
position: absolute;
width: 200px height: 200px;
overflow: hidden;
border-radius: 40%;
}
.shine-box:before {
position: absolute;
top: 0;
left: -500px;
content: "";
width: 120px;
height: 500px;
background: rgba(255, 255, 255, 0.6);
transform: skew(-50deg);
transition: 1s;
}
.shine-box:hover:before {
left: 655px;
}
<div class="shine-box">
<img class="neko" src="neko-fin.png" alt="neko.png">
</div>
Is this something you are looking for. As #Pete suggested you have to use CSS animation instead of transition
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: darkblue;
}
img {
border: 0;
width: 100%;
}
.shine-box {
position: absolute;
width: 200px;
height: 200px;
overflow: hidden;
border-radius: 40%;
}
.shine-box:before {
position: absolute;
top: 0;
left: -500px;
content: "";
width: 120px;
height: 500px;
background: rgba(255, 255, 255, 0.6);
transform: skew(-50deg);
/* transition: 1s; */
animation: shine 3s ease infinite;
}
#keyframes shine {
from {left: -500px;}
to {left: 655px;}
}
/* .shine-box:hover:before {
left: 655px;
} */
<div class="shine-box">
<img class="neko" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEBUQEBIVFRAQDxUVDw8QFw8VFRUQFRUWFhcVFRUYHiggGBolGxUVITIhJikrLi4uFx8zODMtNygtLisBCgoKDQ0NDg0NDysZFRkrLTc3LSsrKy0rKysrLSsrKy03KystKzcrKysrKysrKysrKysrKysrKysrKysrKysrK//AABEIAOUA3AMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAAAgMEBQYHAQj/xABMEAABAwICBgYGBgYHBwUAAAABAAIDBBEFIQYSMUFRYQcTInGBkRQyQlKhsSMzYnKC0VNjc5LBwggVJEPS4vAWVKOys+HxFzV0k6L/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oADAMBAAIRAxEAPwDtKEIQCEIQCEIQCEIQCEIQCEkyAb14JAgWhetF0OACDxCZfOAmHYkwbQfggmoUFuLQHa8D71x8VLjka4XaQRxaQfkgWhCEAhCEAhCEAhCEAhCEAhCEAhCEAhCEAvCUh0nBNvfbMoFvmAUR0jnHlwVXjGP09OQJn9t31cEYdJK77sbbuPkoLajFan6iCOkiOyatPWSkcRTxmw/E7wRGmjYmKzG6OnznqYY/2kkbfgSsTjIw2nv/AFri0szxmYBKY29wgprEj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OoOi3DqT6XE6vXN7lmsImE8Npe49xCBOL9KtdXyejYNTP1nZdaWh8luIb6rBzJPgpej3RW1rjXY9Pru9Z0JeSL/rZNrt3ZHmVp8OxJkUfVYXRtji/TSNMUfeG+vIeZt3pQo3PcJKh5mkGwuyY37kYyHftRE+TF3PYIaRnUUrRqtcGhrnNG6NnsN57UzHGGiw2JbGkmwFydgCuqDB/al8Gf4j/BBDw7DXS9p2UfHeeQ/NaOOMNAa0WA2AJQCEUIQhAIQhAIQhAIQhAIQhB45oIsRcEWIOYI5rFaXaBCpjPokggl3NcCYnHnbNveLjktshB88YZ0bVkE+vWx5h3Ze068feHD+NiumYZoxC9mpLE17fdeAR8Vu0hsbRsAHcgy3+wrGi9LVVNMb31WPEsfd1cwcAO6yh1GF4tDfVnpagbhIyaB3i5pcPgtw8m2SraqGQ7BfuIRGHmqsQH1uHxv5xTxO+EjWqG+uk34O8nkaA/zrYTwy72O8ioxhf7rvIoM5FiNQPq8L1eGvJSN/wCUlPNrcVfkIaWHgXyTSkfha1o+KvRTvOxjvJydZh8x2Md45fNBnP6urZPr654G9lKxkLT+I6z/ACIUiiwKmhOs2O8n6WUukkP43klaOPBZTt1W95v8lNhwNg9dxdyGQ/NBQtaSbAXPAKxpMHkdm/sjn63luV7DTsZkxoHdt806hEelo2RDsjPe45k+KkIQihCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIBCEIP/Z" alt="neko.png">
</div>

Issue with positioning arrow indicators at the right place

I'm tring to create and put two arrow indicators at the right and left edge of the screen, but so far I'm unable to find a solution for these two issues:
I can't put the arrow sign to the center of the dark container. As you can see they are outside of the container right now! (Although I used flex container with center positioning)
Although we can hard code the position of the elements to the edges of the screen with left property I need a proper solution to correctly position the indicators at the edges in any size of the screen.
Here is the code:
.arrow-container {
width: 100%;
left: 25%;
top: 50vh;
position: absolute;
margin: 0 auto;
opacity: 1;
display: flex;
align-items: center;
justify-content: center;
-webkit-perspective: 5000;
z-index: 12;
}
#left-arrow {
left: -22%;
position: absolute;
}
#right-arrow {
right: 28%;
position: absolute;
}
.arrow-container > div {
width: 50px;
height: 50px;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.5);
border-radius: 5px;
background-color: #3b3a3a;
position: relative;
transform-style: preserve-3d;
transform-origin: center center;
transition: transform 200ms;
-webkit-backface-visibility: hidden;
transform: translateZ(0.35rem);
align-items: flex-start;
padding: 10px;
font-size: 5em;
margin: 6px;
filter: drop-shadow(1px 1px 1px #100021) drop-shadow(1px 0.01em 1px #0d021a);
transition: background 200ms, transform 300ms;
}
.arrow-container > div span {
}
.key-arrow {
}
<div class="arrow-container">
<div id="left-arrow" class="key-arrow"><span>🢐</span></div>
<div id="right-arrow" class="key-arrow"><span>🢒</span></div>
</div>
Add some css to these ID#right-arrow,#left-arrow
.arrow-container {
width: 100%;
left: 25%;
top: 50vh;
position: absolute;
margin: 0 auto;
opacity: 1;
display: flex;
align-items: center;
justify-content: center;
-webkit-perspective: 5000;
z-index: 12;
}
#left-arrow {
left: -22%;
position: absolute;
}
#right-arrow {
right: 28%;
position: absolute;
}
.arrow-container > div {
width: 50px;
height: 50px;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.5);
border-radius: 5px;
background-color: #3b3a3a;
position: relative;
transform-style: preserve-3d;
transform-origin: center center;
transition: transform 200ms;
-webkit-backface-visibility: hidden;
transform: translateZ(0.35rem);
align-items: flex-start;
padding: 10px;
font-size: 5em;
margin: 6px;
filter: drop-shadow(1px 1px 1px #100021) drop-shadow(1px 0.01em 1px #0d021a);
transition: background 200ms, transform 300ms;
}
.arrow-container > div span {
}
.key-arrow {
}
#right-arrow,#left-arrow{
display: flex;
justify-content: center;
align-items: center;
line-height: 1;
}
<div class="arrow-container">
<div id="left-arrow" class="key-arrow"><span>🢐</span></div>
<div id="right-arrow" class="key-arrow"><span>🢒</span></div>
</div>

Extra pixel in before and after pseudo elements

I'm trying to create a background effect using before and after pseudo elements by making it one pixel taller and wider than the actual element, but it always seems to have one extra pixel to the right or left. This only happens when the browsers is maximized (Firefox, Chrome and Edge), but does not happen when the browser has a smaller width.
*, *::before, *::after{ box-sizing: border-box; }
body {
display: flex;
flex-flow: column wrap;
justify-content: center;
align-items: center;
background-color: #111;
}
img {
max-width: 300px;
display: block;
padding: 4px;
}
.main-box {
position: relative;
}
.img-box {
padding: 0;
margin: 0;
background-color: #000;
}
.img-box::before{
content: '';
position: absolute;
top: -1px;
left: -1px;
right: -1px;
bottom: -1px;
filter: blur(10px);
z-index: -2;
}
.img-box::after{
content: '';
position: absolute;
top: -1px;
left: -1px;
right: -1px;
bottom: -1px;
z-index: -1;
}
.img-box::before, .img-box::after{
background-image: linear-gradient(45deg, #ff0000, #111, #0000ff);
opacity: 0.7;
transition: opacity ease-out 150ms;
}
.main-box:hover .img-box::after {
opacity: 1;
}
<div class="main-box">
<div class="img-box"><img src="https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png" alt="keyboard"></div>
</div>
It's not quite clear in the picture, but in the browser all sides of the background-image is 1px more except for the left side where it's 2px more.
OUTPUT: Thicker line on the left
This looks like antialiasing. I guess you have either your browser's either your OS's zoom level set to something else than 100%.
Some browsers will try to round the positionning, but at some zoom level, this can't be done properly and you'll end up having one side floored and the other ceiled.
To circumvent this, you can use the translate property which should allow proper antialiasing to kick in (it will be blurry, but of the same size).
*, *::before, *::after{ box-sizing: border-box; }
body {
display: flex;
flex-flow: column wrap;
justify-content: center;
align-items: center;
background-color: #111;
}
img {
max-width: 300px;
display: block;
padding: 4px;
}
.main-box {
position: relative;
}
.img-box {
padding: 0;
margin: 0;
background-color: #000;
}
.img-box::before{
content: '';
position: absolute;
top: 0px;
left: 0px;
width: calc( 100% + 2px );
height: calc( 100% + 2px );
transform: translate(-1px,-1px);
filter: blur(10px);
z-index: -2;
}
.img-box::after{
content: '';
position: absolute;
top: 0px;
left: 0px;
width: calc( 100% + 2px );
height: calc( 100% + 2px );
transform: translate(-1px,-1px);
z-index: -1;
}
.img-box::before, .img-box::after{
background-image: linear-gradient(45deg, #ff0000, #111, #0000ff);
opacity: 0.7;
transition: opacity ease-out 150ms;
}
.main-box:hover .img-box::after {
opacity: 1;
}
<div class="main-box">
<div class="img-box"><img src="https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png" alt="keyboard"></div>
</div>

How to properly use z-index in this case?

I need my h1 "Мышонок" to remain fully visible when I click hamburger menu.
When I click the menu, my white h1 becomes behind it, and I can't figure out how to make it 100% visible.
I tried to mess with z-index but I was unfortunate. Noob here. Please help
#import url("https://fonts.googleapis.com/css?family=Oswald:200,300,400,500,600,700&display=swap");
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
font-family: "Oswald", sans-serif;
}
img {
width: 100%;
height: auto;
}
/* Utility */
.container {
margin: 0 auto;
max-width: 1160px;
padding: 0 20px;
overflow: hidden;
}
.overlay {
top: 0;
left: 0;
right: 0;
bottom: 0;
position: absolute;
background-color: rgba(0, 0, 0, 0.5);
z-index: 999;
}
.hidden {
display: none;
}
/* Home */
.showcase {
position: relative;
height: 100vh;
background-image: url(../img/homebg/bg1.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
animation: slide 18s infinite;
transition: 100ms ease-in-out;
width: 100%;
}
.showcase h1 {
font-size: 3.5rem;
font-weight: 500;
color: #fff;
padding-top: 40px;
text-transform: uppercase;
z-index: 1001;
}
#keyframes slide {
0% {
background-image: url(../img/homebg/bg1.jpg);
}
20% {
background-image: url(../img/homebg/bg2.jpg);
}
40% {
background-image: url(../img/homebg/bg3.jpg);
}
60% {
background-image: url(../img/homebg/bg4.jpg);
}
80% {
background-image: url(../img/homebg/bg5.jpg);
}
100% {
background-image: url(../img/homebg/bg1.jpg);
}
}
.menu-wrap {
position: fixed;
top: 0;
left: 0;
z-index: 1001;
width: 100%;
height: 100%;
}
.menu-wrap .toggler {
position: absolute;
top: 55px;
right: 280px;
z-index: 1002;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0;
}
.menu-wrap .hamburger {
position: absolute;
top: 55px;
right: 270px;
z-index: 1001;
width: 70px;
height: 60px;
padding: 1rem;
background: transparent;
display: flex;
align-items: center;
justify-content: center;
}
/* Hamburger Icon */
.menu-wrap .hamburger>div {
position: relative;
flex: none;
width: 100%;
height: 4px;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.4s ease;
}
.menu-wrap .hamburger>div::before,
.menu-wrap .hamburger>div::after {
content: "";
position: absolute;
z-index: 1;
top: -10px;
width: 100%;
height: 4px;
background: inherit;
}
.menu-wrap .hamburger>div::after {
top: 10px;
}
/* Toggler Animation */
.menu-wrap .toggler:checked+.hamburger>div {
transform: rotate(135deg);
}
.menu-wrap .toggler:checked+.hamburger>div:before,
.menu-wrap .toggler:checked+.hamburger>div:after {
top: 0;
transform: rotate(90deg);
}
.menu-wrap .toggler:checked:hover+.hamburger>div {
transform: rotate(225deg);
}
/* Show Menu */
.menu-wrap .toggler:checked~.menu {
visibility: visible;
}
.menu-wrap .toggler:checked~.menu>div {
transform: scale(1);
transition-duration: 0.75;
}
.menu-wrap .toggler:checked~.menu>div>div {
opacity: 1;
transition: opacity 0.1s ease 0.1s;
}
/* Menu overlay */
.menu-wrap .menu {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
visibility: hidden;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.menu-wrap .menu>div {
background: rgba(0, 0, 0, 0.5);
width: 200vw;
height: 200vw;
display: flex;
flex: none;
align-items: center;
justify-content: center;
transform: scale(0);
transition: all 0.4s ease;
border-radius: 50%;
}
.menu-wrap .menu>div>div {
text-align: center;
max-width: 90vw;
max-height: 100vh;
opacity: 0;
transition: opacity 0.4s ease;
}
.menu-wrap .menu>div>div>ul>li {
list-style: none;
font-size: 3rem;
padding: 1rem;
}
.menu-wrap .menu>div>div>ul>li>a {
color: #fff;
text-decoration: none;
}
<div class="hidden">
<img src="img/homebg/bg2.jpg" />
<img src="img/homebg/bg3.jpg" />
<img src="img/homebg/bg4.jpg" />
<img src="img/homebg/bg5.jpg" />
</div>
<!-- Home -->
<div class="showcase">
<div class="overlay">
<div class="container">
<h1>Мышонок</h1>
<!-- Hamburger -->
<div class="menu-wrap">
<input type="checkbox" class="toggler" />
<div class="hamburger">
<div></div>
</div>
<div class="menu">
<div>
<div>
<ul>
<li>Personal</li>
<li>Men</li>
<li>Women</li>
<li>Video</li>
<li>About</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I don't know what more details to add, stackoverflow, I believe I described it as much as I could
Here is What I was able to come up with to be able to solve your issue: https://jsfiddle.net/L7ac6j3v/8/
One of the main issues I think you were facing was over complicating it for yourself by using crazy z-index values like 999 to 1005 etc, you'll see I have removed or replaced alot of the values with easy to work with values like 1,2 etc
Another main issue I was seeing was your use of the position style and not having position: absolute when trying to work with the z-index of an element
As a side note a way that I like to test if elements are positioned correctly is to use cursor: pointer and pointer-events
Hope this helps :)

CSS Slide effect into container

I'd like to get this effect:
But I cant move only the content, leaving fixed the container. If you see my fiddle, I'm moving all together, the content and the container.
And even I'd like to put the hover on the circle div, not in the content like it is right now, because now when the animation ends it losing the hover.
A little detail to keep in mind:
I need to update at runtime the text to display due it should be
translated depending on the language selected by the user.
Here is my fiddle
.frame {
display: flex;
background-color: green;
height: 200px;
width: 200px;
flex-direction: center;
justify-content: center;
align-items: center;
}
.oval {
display: flex;
background-color: white;
border-radius: 50px;
width: 100px;
height: 100px;
}
.box {
display: flex;
flex-direction: column;
background-color: gray;
height: 100px;
width: 100px;
position: relative;
top: 25px;
transition: top 200ms ease-in;
border-radius: 50px;
}
.box:hover {
top: -50px;
transition: top 200ms ease-in;
animation: ticker 25s cubic-bezier(1, 0, .5, 0);
}
#keyframes ticker {
0% {
margin-top: 0
}
25% {
margin-top: -30px
}
50% {
margin-top: -60px
}
75% {
margin-top: -90px
}
100% {
margin-top: 0
}
}
.box-inn {
flex: 1;
margin: 5%;
color: white;
text-align: center;
align-items: center;
}
.first {
background-color: blue;
}
.second {
background-color: red;
}
<div class="frame">
<div class="oval">
<div class="box">
<div class="box-inn first">
Text 1
</div>
<div class="box-inn second">
Text 2
</div>
</div>
</div>
</div>
You can use pseudo-elements. First hide :after with transform: translateY(100%) and overflow: hidden on parent, and on hover you translate :before for 100% and move :after to 0.
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: 'Top';
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: 'Bottom';
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
<div class="elem"></div>
If you don't want to use pseudo-elements Fiddle
If your icons are images you may want a non-pseudo element method. Here's an example using a font awesome icon to illustrate an image (fa icons can be used with pseudo elements, however)
.link {
position: relative; /* for absolute positioned children to work */
display: inline-flex;
flex-direction: column;
height: 100px; /* this method uses absolutely position chldren so..*/
width: 100px; /* ..a fixed width and height was needed */
color: white;
border-radius: 100%;
border-color: white;
border-style: solid;
border-width: 2px;
overflow: hidden; /* hides the overflowing elements */
}
.icon {
position: absolute;
top: 50%; /* vertically position icon in center in combination with transform -50% */
left: 50%; /* same deal with horizontal centering */
transform: translate(-50%, -50%); /* horizontal, vertical */
transition: all 0.2s ease;
}
.text {
position: absolute;
top: 150%; /* positions text under the .link container element */
left: 50%;
transform: translate(-50%, -50%);
transition: all 0.2s ease;
}
.link:hover .icon {
top: -50%; /* positions icon above the .link container element */
}
.link:hover .text {
top: 50%; /* moves text into center of .link container element */
}
/* styling - ignore */
body {display: flex;justify-content: center;align-items: center; height: 100vh;margin: 0;font-size: 24px;background-color: hsl(189, 72%, 45%);font-variant: small-caps;font-family: verdana;}.icon i {font-size: 40px;}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<a class="link" href="https://jsfiddle.net/Hastig/4akmbgc1/">
<div class="icon"><i class="fa fa-home"></i></div>
<div class="text">fiddle</div>
</a>
fiddle
https://jsfiddle.net/Hastig/4akmbgc1/
Following #Nenad Vracar answer:
On:
I need to update at runtime the text to display due it should be
translated depending on the language selected by the user.
You can use data-attributes along with the attr() CSS function in the pseudo-elements' content property.
Note: Change these data-attributes with JS in your language handling logic.
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: attr(data-top-text);
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: attr(data-bottom-text);
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
<div class="elem" data-top-text="top_text" data-bottom-text="bottom_text"></div>
Another alternative is to use the :lang pseudo-class.
Using lang attribute in the element.
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: "top_text";
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: "bottom_text";
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
.elem:lang(es):before {
content: "texto_superior";
}
.elem:lang(es):after {
content: "texto_inferior";
}
<div class="elem"></div>
<div class="elem" lang="es"></div>
Changing the html lang attribute:
document.getElementById('change-lang').addEventListener('click', function() {
document.documentElement.setAttribute('lang', 'es');
});
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: "top_text";
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: "bottom_text";
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
:lang(es) .elem:before {
content: "texto_superior";
}
:lang(es) .elem:after {
content: "texto_inferior";
}
<div class="elem"></div>
<button id="change-lang">Cambiar a Español</button>