CSS3 Zoom animation with border-radius - css

I need a way to make a zoom animation with CSS3 in a div with border-radius. But as you can see below, it doesn't work well:
Working Code: https://jsfiddle.net/n5owxmch/
CSS:
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.item {
position: relative;
border-radius: 10px;
border: 1px solid #333;
margin: 2%;
overflow: hidden;
width: 540px;
}
.item img {
max-width: 100%;
-moz-transition: all 21s;
-webkit-transition: all 21s;
transition: all 21s;
}
.item:hover img {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
HTML:
<div class="item">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s600x600/e35/17661731_634657496725091_8999479055321399296_n.jpg" alt="pepsi" width="540" height="548">
<div class="item-overlay top"></div>
</div>
Is there a way to fix that ?

From my research I reproduced this just in Chrome (Edge and Firefox works fine). To solve it I added z-index and vendor prefixes for border-radius see below .
Prioritize the .item by adding z-index: 100; and deprioritize the image with z-index: 0;. Basically this will enforce the image to be under the .item.
And I added vendor-prefixes (-moz- and -webkit-) for border-radius:
-moz-border-radius:10px; /* add this */
-webkit-border-radius: 10px; /* add this */
See snippet:
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.item {
z-index: 100; /* add this */
position: relative;
-moz-border-radius:10px; /* add this */
-webkit-border-radius: 10px; /* add this */
border-radius: 10px;
border: 1px solid #333;
margin: 2%;
overflow: hidden;
width: 540px;
}
.item img {
max-width: 100%;
z-index: 0; /* add this */
-moz-transition: all 2s;
-webkit-transition: all 2s;
transition: all 2s;
}
.item:hover img {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
<div class="item">
<img src="https://scontent.cdninstagram.com/t51.2885-15/s600x600/e35/17661731_634657496725091_8999479055321399296_n.jpg" alt="pepsi" width="540" height="548">
<div class="item-overlay top"></div>
</div>

Related

Text disappears in ie

I have tried adding z-index, experimenting with different div names but I have had no luck.
I tried inspecting the element but it is almost as if the sidebar is going above the entire website and outside the parent div...
Any input would be greatly appreciated.
A couple of pointers
I added to .sidebar
top:100%;
left:0;
and I took out
translate(1em,0) /*This was causing bar to shift instead of bracing to window*/
here is a working snippet
html, body {
margin: 0;
height:100vh;
height:100vw;
font-size: 16px;
}
.main {
background-color: blue;
height:100vh;
width:100vw;
}
.rest {
background-color: blue;
height:100vh;
width:100vw;
}
.sidebar {
z-index: 1000;
display: block;
position: fixed;
transform: translateZ(0);
-webkit-transform: translateZ(0);
white-space: nowrap;
-webkit-transform: rotate(-90deg);
-moz-transform:rotate(-90deg);
-o-transform:rotate(-90deg);
transform:rotate(-90deg);
-ms-transform: rotate(-90deg);
top:100%;
left:0;
padding:0px;
width:100vh;
margin:none;
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
-ms-transform: none;
-ms-transform-origin: none;
-ms-writing-mode: tb-rl;
*writing-mode: tb-rl;
border-right: 1px solid black;
border-right: 1px solid rgba(0,0,0,0.5);
background-color: white;
background-color: rgba(255,255,255,.4);
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<html>
<body>
<div class="main">
<div class="sidebar">
testestestste
</div>
</div>
<div class="rest" style="background-color: yellow;">
</div>
</body>
</html>

CSS – Blurring image with un-blurred text

I have div elements that are 200px tall and 200px wide, and I am filling each div element with an image of a person.
Upon hovering on the image, I want the image to be blurred, but I simultaneously want text to appear on the image (unblurred) that gives a description of who they are. Does anyone know how to do this?
So far, this is what I am getting:
Here is the CSS code:
.mem1 {
height: 200px;
width: 200px;
margin: 0px 31px;
display: inline-block;
border-radius: 10px;
border: solid;
border-width: thin;
border-color: #d6d6d6;
background-image: url(members/giles.png);
}
.mem1 p {
text-align: center;
position: absolute;
margin: 70px 30px;
visibility: hidden;
}
.mem1:hover {
-webkit-filter: blur(2px);
}
.mem1:hover p {
text-align: center;
position: absolute;
margin: 70px 30px;
color: #ffffff;
text-shadow: 1px 1px #000000;
-webkit-filter: blur(0px);
visibility: visible;
}
It sounds like the text is a child of the element that you are blurring. You can't do that. You need to do something like this:
<div class="container">
<div class="blurredPhoto"></div>
<div class="text">Your Text</div>
</div>
.container {
width: 200px;
height: 200px;
position: relative;
}
.blurredPhoto {
position: absolute;
width: 200px;
height: 200px;
}
.text {
position: absolute;
width: 200px;
height: 200px;
}
Then apply your blurring logic only to the .blurredPhoto object.
Here is a code snippet that does what you are looking for - blurring an image when you mouse over it, while simultaneously showing a textual description.
The key is that you need to use the :hover pseudoclass on the div, then when the div is hovered, you blur the image only, and show the description text span.
.blur {
width: 350px;
height: 350px;
}
.blur img {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.blur span {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.blur:hover img {
-webkit-filter: blur(5px);
}
.blur span {
opacity: 0;
position: absolute;
top: 30px;
left: 30px;
}
.blur:hover span {
opacity: 1;
}
<div class="blur pic">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97350&w=350&h=350">
<span>This is a photo of something.</span>
</div>
As #DA explained you need to get a parent container involved. Here's a working fiddle using your example code: https://jsfiddle.net/m25gkqkL/1/
<div class="parent">
<div class="mem1"></div>
<p>Hello World!</p>
</div>
.mem1 {
height: 200px;
width: 200px;
margin: 0px 31px;
display: inline-block;
border-radius: 10px;
border: solid;
border-width: thin;
border-color: #d6d6d6;
background-image: url(members/giles.png);
z-index: 1;/* added */
position: relative;/* added */
}
.parent {/* added this */
position: relative;
height: 200px;
width: 262px;
}
.parent p {/* modified */
text-align: center;
position: absolute;
visibility: hidden;
top: 50%;/* modified */
margin-top: -0.5em;/* added */
width: 262px;/* added */
z-index: 2;/* added */
}
.parent:hover .mem1 {/* modified */
-webkit-filter: blur(2px);
}
.parent:hover p {/* modified */
color: #ffffff;
text-shadow: 1px 1px #000000;
-webkit-filter: blur(0px);
visibility: visible;
}
.parent{
position: relative;
}
.text-child{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: all .3s ease;
z-index: 1;
}
.text-child h1{
color: black;
text-decoration: none;
font-size: 40px;
}
.parent:hover img{
filter: blur(4px);
}
.parent:hover .text-child{
opacity: 1;
}
<div class="parent">
<div class="text-child">
<h1> hi this is text.<h1>
</div>
<img src="/images/excel.png" alt="">
</div>

Safari stacking issue with 3d transformed elements

I've read through numerous similar issues regarding this topic, but haven't been able to solve my problem using any of those advices, so giving it a shot to see what I might be doing wrong / how I can solve this :)
I'm trying to get #item-2 to stack in front of #item-1 . This works fine in Chrome etc..but fails in Safari. Any advice would be greatly appritiated.
I have the following html elements:
html,
body {
min-height: 100%;
backround: #FFF;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#scene-bg,
#scene {
position: absolute;
top: 0;
left: 0;
}
#grid {
-webkit-perspective: 865px;
-moz-perspective: 865px;
perspective: 865px;
width: 987px;
height: 720px;
position: absolute;
top: 0;
left: 0;
z-index: 1;
border: 1px solid;
}
.inner {
width: 100%;
height: inherit;
position: relative;
top: 17px;
left: 6px;
border: 1px solid;
-webkit-transform: rotateX(-0.3302deg) rotateY(20.5164deg) rotateZ(-0.8716deg);
-moz-transform: rotateX(-0.3302deg) rotateY(20.5164deg) rotateZ(-0.8716deg);
transform: rotateX(-0.3302deg) rotateY(20.5164deg) rotateZ(-0.8716deg);
}
#item-1 {
position: relative;
width: 100%;
height: inherit;
-webkit-transition: background .25s ease-out;
-moz-transition: background .25s ease-out;
transition: background .25s ease-out;
background: red;
}
#item-2 {
position: absolute;
z-index: 99999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: blue;
}
<div id="grid">
<div class="inner">
<div id="item-1">
</div>
<!-- /#item-1 -->
</div>
<!-- /.inner -->
<div id="item-2">
</div>
<!-- /#item-2 -->
</div>
<!--/#grid -->

3D transform issue in firefox

I have a JSFiddle showing a flipping card, It works in chrome as I would expect but the depth perspective in firefox is flat and I'm not sure where the issue is.
I have tried adding:
transform-style: preserve-3d;
and
perspective: 1000;
to all classes (like card) I could with no luck.
The HTML structure is:
<div id="card-container">
<button id="card-flip">Flip the card</button>
<div id="card">
<div class="front card-surface"><!-- front -->
<p>The front</p>
</div>
<div class="back card-surface"><!-- back -->
<p>The back</p>
</div>
</div>
</div>
The simplified CSS is:
#card-container{
position: relative;
background-color:#888;
width: 300px;
height: 450px;
margin:0 auto;
}
#card-flip{
display:none;
}
#card{
margin:10px auto;
width: 100%;
height: 400px;
}
.card-surface{
margin-top:5px;
width: 280px;
height: 180px;
padding:10px;
}
.front{
background-color:#7B78E8;
}
.back{
background-color:#78AFE8;
}
/* Only apply 3d effects if they exist in the browser */
#card-container.threed{
height: 250px;
perspective: 1000;
}
.threed #card-flip{
background-color:transparent;
position:relative;
top:220px;
width:100%;
height:40px;
background-color:#99E5FF;
}
.threed #card-flip:focus{
outline:0;
}
.threed #card-flip:hover{
background-color:#49A5BF;
}
#card-flip:hover + #card .card-surface{
box-shadow: 0 0px 50px rgba(0,0,0,0.9);
transition: all .8s ease-in-out;
}
.threed #card{
height:200px;
}
.threed #card .front {
float: none;
position: absolute;
top: 0;
left: 0;
z-index: 900;
transform: rotateX(0deg) rotateY(0deg);
transform-style: preserve-3d;
backface-visibility: hidden;
}
.threed #card.flip .front {
z-index: 900;
border-color: #eee;
background: #333;
box-shadow: 0 15px 50px rgba(0,0,0,0.2);
transform: rotateY(180deg);
}
.threed #card .back {
float: none;
position: absolute;
top: 0;
left: 0;
z-index: 800;
border: 1px solid #ccc;
text-shadow: 1px 1px 1px rgba(0,0,0,0.6);
transform: rotateY(-180deg);
transform-style: preserve-3d;
backface-visibility: hidden;
}
.threed #card.flip .back {
z-index: 1000;
background-color:#ccc;
transform: rotateX(0deg) rotateY(0deg);
}
.threed #card .card-surface{
background-color:$base-white;
transition: all .8s ease-in-out;
width: 280px;
height: 180px;
padding:10px;
}
I have seen working examples like This one. Can anyone tell me what I am missing or is it not possible with this structure?
I have figured out the issue.
Here is a new version of the fiddle.
The problem was that I did not have the px after the perspective property. this was ignored by chrome but not firefox. I also applied The perspective to the wrong element in the demo so even though I had tried to ad the px before it didn't work.

skewed separation in css

So I was trying to make a skewed separation in CSS (only). It should look kind of like this here: http://i.stack.imgur.com/hVCa1.png
I tried it with CSS transforms already (transform: skew(-15deg);), but I don't think it'll work in all browsers, and it's not really adaptive. I thought about making it with linear gradients, but I'm not sure if this is any better.
Do you guys know of any better solution for this?
EDIT: here's the code:
.results {
width: 500px; }
.transf {
height: 30px;
box-sizing: border-box;
-moz-box-sizing: border-box;
/* Firefox */
display: inline-block;
-moz-transform: skew(-15deg);
-webkit-transform: skew(-15deg);
-o-transform: skew(-15deg);
-ms-transform: skew(-15deg);
transform: skew(-15deg);
background: grey !important;
width: 6px;
margin-left: -4px;
margin-right: -5px;
z-index: 1; }
.left_border {
height: 30px;
box-sizing: border-box;
-moz-box-sizing: border-box;
/* Firefox */
display: inline-block;
-moz-transform: skew(-15deg);
-webkit-transform: skew(-15deg);
-o-transform: skew(-15deg);
-ms-transform: skew(-15deg);
transform: skew(-15deg);
background: yellow;
border-right: 1px solid green;
border-top: 1px solid green;
border-bottom: 1px solid green;
width: 10px;
margin-left: -15px;
z-index: 2; }
.right_border {
height: 30px;
box-sizing: border-box;
-moz-box-sizing: border-box;
/* Firefox */
display: inline-block;
-moz-transform: skew(-15deg);
-webkit-transform: skew(-15deg);
-o-transform: skew(-15deg);
-ms-transform: skew(-15deg);
transform: skew(-15deg);
background: orange;
border-left: 1px solid red;
border-top: 1px solid red;
border-bottom: 1px solid red;
width: 10px;
margin-right: -20px;
z-index: 2; }
.left {
height: 30px;
box-sizing: border-box;
-moz-box-sizing: border-box;
/* Firefox */
display: inline-block;
background: yellow;
width: 30%;
border: 1px solid green;
z-index: 0; }
.right {
height: 30px;
box-sizing: border-box;
-moz-box-sizing: border-box;
/* Firefox */
display: inline-block;
background: orange;
width: 20%;
border: 1px solid red;
z-index: 0; }
.item21 {
width: 5%; }
.item22 {
width: 15%; }
and the HTML:
<div class="results">
<div class="left"></div>
<div class="left_border"></div>
<div class="transf"></div>
<div class="right_border"></div>
<div class="right"></div>
</div>
<div class="results">
<div class="left item21"></div>
<div class="left_border"></div>
<div class="transf"></div>
<div class="right_border"></div>
<div class="right item22"></div>
</div>
As you have pointed out, this can be done with CSS3 only, but not all browsers support it. For full browser support i'd use jQuery
DEMO http://jsfiddle.net/kevinPHPkevin/UkAfD/26/
var skewed = false;
function skew() {
skewed = !skewed;
$('#box').css({
skewY: skewed ? '10deg' : '-10deg'
});
}
There are a few things you could do.
You could use transforms with a polyfill like CSSSandpaper to
make it cross browser compatible. Although, to get that type of
separation (with one side of the div being straight) you may have to
use skew AND perspective.
You could make a faux separator by using the before and after
pseudo classes with the CSS triangle trick. This, too, would
require a polyfill for pseudo classes like Selectivizr. You
would also have to play around with the border-width values to get
it to match what you are looking for.
You could use a PNG using the before/after pseudo classes.
You could use SVG to draw the borders around the containers.
Any of these would work, but its definitely not as easy as, say, rounded corners or drop shadows. You need to put in a little extra work to get those types of results.

Resources