Transform Scale makes Div with border-radius Blurry - css

Basically, when I hover over a div, I increase the scale with transform. This div has a border-radius, and when it scales, it gets blurry. In the JSFIDDLE example, the blur happens then goes away, but on my localhost site, it stays blurry.
Is it just happening to my screen, or is anyone else seeing this too?
JSFIDDLE LINK https://jsfiddle.net/3arynm5v/
HTML
<div class="circle">
<div class="circle--inner"></div>
<div class="circle--outer"></div>
</div>
SCSS
.circle {
width:300px;
height:300px;
background:black;
position:relative;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 1000;
perspective: 1000;
&:hover &--inner {
transform:scale(7);
}
&--inner, &--outer {
position:absolute;
margin:0 auto;
left:0; right:0;
top:50%;
transform:translateY(-50%);
border-radius:200%;
}
&--inner {
width:10px;
height:10px;
background:white;
transition:transform 1s;
transform-origin: center center;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 1000;
perspective: 1000;
}
&--outer {
width:30px;
height:30px;
border:5px solid white;
}
}

What transform does is take the existing size and zoom in on it. What you can do is set the &--inner on width and height: 70px (10px times the zoom factor 7 from the transform). Position it in the middle and instead of zooming it 7x on hover, scale it down on the normal view.
I've updated the Fiddle to show you what I mean. https://jsfiddle.net/3arynm5v/3/
As you can see I've edited the outer and inner to to:
&:hover &--inner {
transform:translate(0, -50%)scale(1);
top: 50%;
}
&--inner, &--outer {
position:absolute;
margin:0 auto;
left:0; right:0;
top:50%;
border-radius:200%;
}
&--inner {
width:70px;
height:70px;
background:white;
transition:transform 1s;
transform-origin: center center;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 1000;
perspective: 1000;
transform: translate(0, -50%)scale(.1);
}
&--outer {
width:30px;
height:30px;
border:5px solid white;
transform:translateY(-50%);
}

Related

Use CSS animation to reveal text from center and keep text visible at end

I'm using code from Reveal Text from center with CSS Animation to reveal text from the center. But I'd like to keep the text visible after the animation is over. Right now, the text disappears after the animation. I'm new to css animation, so I'm not sure what the right thing to do is.
css:
.text-div {
color:white;
text-align:center;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
top:45%;
font-weight: bold;
}
.text-div:before {
left:0;
}
.text-div:after {
right:0;
}
.text-div:after,.text-div:before {
position:absolute;
content:"";
height:100%;
width:50%;
background:black;
animation: revealText 3s;
}
.content {
background:black;
height:200px;
width:200px;
position:relative;
}
#keyframes revealText {
0% {
width:50%
}
100% {
width:0%
}
}
html:
<div class="content">
<div class="text-div">
The subculture
</div>
</div>
Add animation-fill-mode:forwards to .text-div:after,.text-div:before as below,
.text-div:after,.text-div:before {
position:absolute;
content:"";
height:100%;
width:50%;
background:black;
animation: revealText 3s;
animation-fill-mode:forwards; /*Add this*/
}
The animation-fill-mode CSS property specifies how a CSS animation
should apply styles to its target before and after it is executing.
.text-div {
color:white;
text-align:center;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
top:45%;
font-weight: bold;
}
.text-div:before {
left:0;
}
.text-div:after {
right:0;
}
.text-div:after,.text-div:before {
position:absolute;
content:"";
height:100%;
width:50%;
background:black;
animation: revealText 3s;
animation-fill-mode:forwards;
}
.content {
background:black;
height:200px;
width:200px;
position:relative;
}
#keyframes revealText {
0% {
width:50%
}
100% {
width:0%
}
}
<div class="content">
<div class="text-div">
The subculture
</div>
</div>

Image hover overlay with text - text position

Good evening,
I am trying to make image hover overlay with text, but displayed text is always on the top of the image. I would like to display it in the middle of it.
I've tried padding etc, but it moved the overlay as well, that it covered also the free space below the image. Could you please help me, how to margin only text from top? Thank you!
EDIT: Or the best solution would be, if I could include another div with text only. Because I need to include text with html tags and it's not possible this way, via "content:"
http://jsfiddle.net/sL6bjebx/
Here is CSS code:
.image {
position:relative;
margin: 0 auto;
}
.image img {
width:100%;
vertical-align:;
}
.image:after {
content:'Here is some text..';
color:#fff;
position:absolute;
width:100%; height: 100%; max-height:100%;
top:0; left:0;
background:rgba(0,0,0,0.75);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.image:hover:after {
opacity:1;
}
If your overlay text is going to be a one liner then you can use line-height css property to make it vertically center aligned
.image:after {
content:'Here is some text..';
color:#fff;
position:absolute;
width:100%; height: 100%; max-height:100%;
top:0; left:0;
background:rgba(0,0,0,0.75);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
line-height:300px;
}
and if not, then I will suggest to use another way to display the content.
such as :before just like this fiddle, Or you can use a <p> tag as well instead of the :before tag check this fiddle.
.image:after {
content:'';
color:#fff;
position:absolute;
width:100%; height: 100%; max-height:100%;
top:0; left:0;
background:rgba(0,0,0,0.75);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
z-index:1
}
.image:before {
content:'Here is some text..';
color:#fff;
position:absolute;
width:100%; height: 20px;
top:0; left:0; right:0;
bottom:0;
opacity:0;
margin:auto;
z-index:2
}
.image:hover:after {
opacity:1;
}
.image:hover:before {
opacity:1;
}
Here is the solution with another div or something, where would be possible to insert text with HTML tags:
.image {
position:relative;
margin: 0 auto;
width: 317px;
height: 317px;
text-align: center;
}
.image img {
width:100%;
vertical-align:;
}
.image .overlayText {
color:#fff;
position:absolute;
width:100%; height: 100%; max-height:100%;
line-height:317px;
top:0; left:0;
background:rgba(0,0,0,0.75);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
margin:0;
}
.image:hover > .overlayText {
opacity:1;
}
<div class="image">
<img src="http://media.tumblr.com/tumblr_m6v66lJ5K61r0taux.jpg">
<p class="overlayText"><b>Here</b> is some text</p>
</div>
You should simply add line-height
.image {
position:relative;
margin: 0 auto;
}
.image img {
width:100%;
vertical-align:;
}
.image:after {
content:'Here is some text..';
color:#fff;
position:absolute;
width:100%; height: 100%; max-height:100%;
line-height:317px;
top:0; left:0;
background:rgba(0,0,0,0.75);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.image:hover:after {
opacity:1;
}
<div class="image" style="width: 317px; height: 317px; text-align: center;">
<img src="http://media.tumblr.com/tumblr_m6v66lJ5K61r0taux.jpg">
</div>

Text on image not displaying

Text on my image is not appearing. Its animating but i want text on my image on mouse hover. For text I used button with image that suppose to popup on mouse hover.let me know my mistake. I am using this code from youtube tutorial.
.main
{
border: 10px solid white;
width:378px;
height:250px;
margin:50px auto;
box-shadow:0px 0px 25px black;
overflow:hidden;
}
.main:hover img
{
-webkit-transform:scale(2,2) rotate(45deg);
}
.main:hover .content
{
-webkit-transform:translate(-311px);
}
img
{
-webkit-transition: -webkit-transform: 300ms;
}
.content
{
width:378px;
height:250px;
background: rgba(124,120,120,0.5);
-webkit-transition: -webkit-transform: 300ms;
}
button
{
width:100%;
height:50px;
margin-top:200px;
background:black;
border:0;
cursor:pointer;
color:white;
font:16px tahoma;
}
button:hover {
opacity: 0.5;
}
<div class="main"><img src="img/switch.jpg" height="250" width="378"><div class="content"><button>Pepe Kalvier Switches</button></div></div>
You can use the position absolute to move your text/button above the image when hover.
CSS
.main:hover .content{
z-index: 9999;
position: absolute;
top:0;
}
DEMO HERE
you can try this one:
<div class="main"><img src="http://dev.boutiquevalmont.com/media/wysiwyg/valmont/arts/thb3.jpg" height="250" width="378"><div class="content"><button>Pepe Kalvier Switches</button></div></div>
DEMO

CSS transform and transition

I have a rectangle created in CSS, added a transition so when I hover, the shape shrink and disappear:
.shapeB{
background-color: #FFCC00;
width: 100px;
height: 100px;
-webkit-transition:all 1s;
}
.shapeB:hover{
height:0px;
}
<div class="shapeB"></div>
But the fact that it shrinks up is not what I want, I want it to shrink going down. Trying to stimulate liquid being consumed. Is it possible?
You could somehow missplace the div 100px down, to give that impression. Something like this:
.shapeB{
background-color: #FFCC00;
width: 100px;
height: 100px;
position: relative;
top: 0;
-webkit-transition:all 1s;
}
.shapeB:hover{
height:0px;
top: 100px;
}
<div class="shapeB"></div>
.box{
position:absolute;
width: 100px;
height: 100px;
left:50px;
top:50px;
}
.shapeB{
background-color: #FFCC00;
width: 100px;
height: 100px;
position:absolute;
bottom:0;
-webkit-transition:all 1s;
}
.shapeB:hover{
height:0px;
}
<div class="box">
<div class="shapeB"></div>
</div>

animation to start from center of div using css3 only

Okay here is the thing,
I have the animation centered in the middle of the page and it start automatically as soon as the page loads but I want the animation to start from the middle of the page, expanding towards the right size. Not from the top left corner!!
I know it can be done using jquery but I want to use only CSS.
Any thoughts will be greatly appreciated.
Here is what I have
http://jsfiddle.net/robcabrera/9gXNc/
#container{
width: 700px;
height:350px;
position:absolute;
left:50%;
top:50%;
margin:-175px 0 0 -350px;
}
#intro{
width: 700px;
height:350px;
box-shadow:15px 15px 15px #333;
-webkit-box-shadow:15px 15px 15px #333;/*Safari and Chrome*/
-moz-box-shadow:15px 15px 15px #333;/*Mozilla Firefox*/
border-top: 2px solid #ccc ;
border-left: 2px solid #ccc;
border-radius:10px;
-moz-border-radius:10px;
background: #fff;
animation:welcome 2s;
animation-timing-function:linear;
animation-play-state:running;
-webkit-animation:welcome 2s; /*Safari and Chrome*/
-webkit-animation-timing-function:linear;
-webkit-animation-play-state:running;
}
#keyframes welcome{
from{
width:0px;
height:0px;
}
to {
width: 700px;
height:350px;
}
}
/*Safari and Chrome*/
#-webkit-keyframes welcome{
from{ width:0px; height:0px;}
to {width: 700px; height:350px;}
}
Without changing your code too much:
removed #container - margin, now the container is centered in its top left corner
added margin-left, margin-top to the animation so the intro would animate left/up as it grew
added animation fill-mode: forwards to keep the intro in place when the animation was complete.
Demo Fiddle
CSS
#container {
width: 700px;
height:350px;
position:absolute;
left:50%;
top:50%;
/*margin:-175px 0 0 -350px;*/
}
#intro {
position: relative;
...
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
/*Safari and Chrome*/
-webkit-animation-timing-function:linear;
-webkit-animation-play-state:running;
}
Keyframes (only generic shown here)
#keyframes welcome {
from {
width:0px;
margin-left: 0;
margin-top: 0;
height:0px;
}
to {
width: 700px;
margin-left: -350px;
margin-top: -175px;
height:350px;
}
}

Resources