HTML CSS Ken Burns distorted effect - html

I have a website with a header image ( 3279 x 710 px ) and I added a Ken Burns effect to it, but it seems like it is distorted. I made a fiddle with a test image, but i can't reproduce the distorted effect, however it has something to do with it's aspect ratio. The Image looks like it's pressed together.
Right now i tried to fix it with width set to auto and height to 100%, but I can't get it to work.
I made a fiddle here.
HTML
<div id="header-wrapper" class="wrapper">
<img src='http://eventzerz.com/wp-content/uploads/2018/03/Test-Logo-Small-Black-transparent-1.png' class='image-kenburns'>
<div id="header">
</div>
</div>
CSS
#header-wrapper {
background: transparent;
padding: 0;
}
.wrapper {
padding: 6em 0 9em 0;
}
.wrapper .title {
font-size: 0.9em;
width: 25em;
/*
height: 3.25em;
*/
height: 3.4em;
top: -3.25em;
line-height: 3.25em;
margin-bottom: -3.25em;
margin-left: -12.5em;
padding-top: 0.5em;
}
#header {
position: relative;
padding: 12em 0;
}
.homepage #header {
padding: 18em 0;
}
.image-kenburns {
overflow: hidden;
position: absolute;
z-index: -1;
animation: move 40s ease-in infinite;
height: 100%;
width: 100%;
}
#keyframes move {
0% {
-webkit-transform-origin: bottom left;
-moz-transform-origin: bottom left;
-ms-transform-origin: bottom left;
-o-transform-origin: bottom left;
transform-origin: bottom right;
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
50% {
transform: scale(1.2);
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
-o-transform: scale(1.2);
-moz-transform: scale(1.2);
}
100% {
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
}
EDIT: I should mention that it's fine looking on desktop, what I need is the responsive version for tablets.

If you need your image to resize proportionally / keep the aspect ratio just add to your .image-kenburns class height: auto

Related

Replace an existing vertically centered image, with an existing Ken Burns effect

I’ve 2 pieces of code that work brilliant independently.
The first will vertically and horizontally center an image regardless of brower size. The second produces the Ken Burns effect.
I would like to vertically and horizontally center the Ken Burns effect regardless of browser size.
Thank you in advance for your time and patience.
First:
<div class="parent">
<img class="responsive center" src="https://unsplash.it/900/700">
</div>
------------
parent {
position: relative;
}
.responsive {
max-width: 100%;
max-height: 100%;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Second:
<div class="image-wrap">
<img src="https://unsplash.it/900/700">
</div>
------------
.image-wrap {
width: 100%;
height: 50vw;
margin: 0 auto;
overflow: hidden;
position: relative;
}
.image-wrap img {
width: 100%;
animation: move 40s ease;
-ms-animation: move 40s ease;
-webkit-animation: move 40s ease;
-0-animation: move 40s ease;
-moz-animation: move 40s ease;
position: absolute;
}
#-webkit-keyframes move {
0% {
-webkit-transform-origin: bottom left;
-moz-transform-origin: bottom left;
-ms-transform-origin: bottom left;
-o-transform-origin: bottom left;
transform-origin: bottom left;
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
100% {
transform: scale(1.2);
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
-o-transform: scale(1.2);
-moz-transform: scale(1.2);
}
}
Try this code:
.image-wrap {
width: 100%;
height: 100vh;
margin: 0 auto;
overflow: hidden;
position: relative;
}
.image-wrap img {
animation: move 40s ease;
-ms-animation: move 40s ease;
-webkit-animation: move 40s ease;
-0-animation: move 40s ease;
-moz-animation: move 40s ease;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: 100%;
height: auto;
}
#-webkit-keyframes move {
0% {
-webkit-transform-origin: bottom left;
-moz-transform-origin: bottom left;
-ms-transform-origin: bottom left;
-o-transform-origin: bottom left;
transform-origin: bottom left;
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
100% {
transform: scale(1.2);
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
-o-transform: scale(1.2);
-moz-transform: scale(1.2);
}
}
<div class="image-wrap">
<img src="https://unsplash.it/900/700">
</div>

Image/Link is stuck to top-left, even when position is changed

This is my CSS and HTML.
div.musiclink {
position: relative;
}
a.music {
width: 258px;
height: 117px;
display: block;
background: deepskyblue url('MUSIC-cursive.png') center top no-repeat;
-webkit-transform: rotate(330deg);
-moz-transform: rotate(330deg);
-ms-transform: rotate(330deg);
-o-transform: rotate(330deg);
transform: rotate(330deg);
}
a.music:hover {
background-image: url('MUSIC-cursive-hover.png');
}
a.store {
position: relative;
left: 500px;
top: 100px;
width: 220px;
height: 110px;
display: block;
background: deeppink url('STORE-cursive.png') center top no-repeat;
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
transform: rotate(30deg);
}
a.store:hover {
background-image: url('STORE-cursive-hover.png');
}
<div class="musiclink">
</div>
<div class="storelink">
</div>
The thing is I positioned everything successfully when I used images instead of href links, but now nothing is working the way I want it to. I don't want the images/links to move when I resize the browser.

Fitting Diagonal Divs to create a perfect X on page

I need a little help with fitting these diagonal divs to page to create a perfect X that I can then click on to bring either side of the X to the foreground through a js onclick to z-index change. I have all that covered but I've never dealt with diagonal div's and can't seem to make them fit to page properly to form a perfect X without getting a scroll bar:
.x1 {
background-color: #2cb5e8;
opacity: 0.4;
transform: skewY(-145deg);
position: absolute;
overflow: hidden;
padding: 10% 44%;
margin: 10% 0% 0% 0%;
z-index: 1002;
}
.x1>.wrapper {
-webkit-transform: skewY(145deg);
-moz-transform: skewY(145eg);
-ms-transform: skewY(145deg);
-o-transform: skewY(145deg);
transform: skewY(145deg);
}
.x2 {
background-color: #0fb8ad;
opacity: 0.4;
transform: skewY(145deg);
position: absolute;
overflow: hidden;
padding: 10% 44%;
margin: 10% 0% 0% 0%;
z-index: 1001;
}
.x2>.wrapper {
-webkit-transform: skewY(145deg);
-moz-transform: skewY(145deg);
-ms-transform: skewY(145deg);
-o-transform: skewY(145deg);
transform: skewY(145deg);
}
.page {
min-height: 100%;
min-width: 100%;
max-height: 100%;
max-width: 100%;
}
<div class="page">
<div class="x1">
<div class="wrapper">
<br>
</div>
</div>
<div class="x2">
<div class="wrapper2">
<br>
</div>
</div>
</div>
Since you are dealing with javascript. You can simply get the distance of the box from the top of the container .page and add a padding-top to .page container itself.
Get the dimension of one of the bar example bar with class .x1
Compute the top position of .x1 and padding the parent to shift down its contents
Snippet below
document.getElementsByClassName("page")[0].style.paddingTop=-(document.getElementsByClassName("x1")[0].getBoundingClientRect().top)+"px";
.x1 {
background-color: #2cb5e8;
/*opacity: 0.4;*/
transform: skewY(-145deg);
position: absolute;
overflow: hidden;
padding: 10% 44%;
margin: 10% 0% 0% 0%;
z-index: 1002;
}
.x1>.wrapper {
-webkit-transform: skewY(145deg);
-moz-transform: skewY(145eg);
-ms-transform: skewY(145deg);
-o-transform: skewY(145deg);
transform: skewY(145deg);
}
.x2 {
background-color: #0fb8ad;
/*opacity: 0.4;*/
transform: skewY(145deg);
position: absolute;
overflow: hidden;
padding: 10% 44%;
margin: 10% 0% 0% 0%;
z-index: 1001;
}
.x2>.wrapper {
-webkit-transform: skewY(145deg);
-moz-transform: skewY(145deg);
-ms-transform: skewY(145deg);
-o-transform: skewY(145deg);
transform: skewY(145deg);
}
.page {
min-height: 100%;
min-width: 100%;
max-height: 100%;
max-width: 100%;
}
<div class="page">
<div class="x1">
<div class="wrapper">
<br>
</div>
</div>
<div class="x2">
<div class="wrapper2">
<br>
</div>
</div>
</div>

Rotating a shape in the div while making another div stay in the same place

I have a diamond shape in one div with an image in it and there is a div with absolute positioned text. On hover, I want the diamond to spin, but not the text. Is it possible to achieve? I suppose I will have to change the HTML a bit.
Here are my attempts so far:
HTML:
<div class="rel">
<div class="dn-diamond">
<h4> Random text </h4>
<div class="dn-diamond-img">
<img src="../images/someImage.png" alt="">
</div>
</div>
</div>
CSS:
.rel {
position: relative;
display: inline;
}
.rel:hover {
animation: spin 3s infinite linear;
}
#keyframes spin {
from { transform: rotateY(0deg); }
to { transform: rotateY(360deg); }
}
.rel:hover .dn-diamond h4 {
-webkit-animation-name: none !important;
animation-name: none !important;
}
.dn-diamond h4 {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
letter-spacing: 0.1em;
text-transform: uppercase;
position: absolute;
top: -20px;
left: 20px;
padding: 10px;
z-index: 10;
background: rgba(0, 0, 0, 0.4);
color: #fff;
}
.dn-diamond-img {
width: 420px;
height: 420px;
}
.dn-diamond-img img {
width: 100%;
height: auto;
-webkit-transform: rotate(45deg) translateX(-95px);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg) translateX(-100px) translateY(45px);
transform-origin: 50% 50%;
overflow: hidden;
}
Thanks for any help!
You refer to it as a diamond, so I assume you want to keep it upright. I think this is what you want: http://jsfiddle.net/t67c7ffq/1/
All I did was change .rel:hover to .dn-diamond-img:hover. This won't spin the h4.
I not sure if you are looking for this:
http://codepen.io/luarmr/pen/qdrvgM
My changes
.rel {
position: relative;
}
.rel:hover img{
animation: spin 3s infinite linear;
}
And as well the animation, because don´t make sense for me the jump
#keyframes spin {
from {
transform: rotate(45deg) translateX(-100px) translateY(45px);
transform-origin: 50% 50%;
}
to {
transform: rotate(405deg) translateX(-100px) translateY(45px);
transform-origin: 50% 50%; }
}
}
Assign an id=myimage to your html <img src="../images/someImage.png" alt="" id="myimage">and then change the css from .rel to #myimage. You only need to spin the image, right?

Rotating a div without rotating its content using CSS3 transformations

I have an image and a div over it which is working as a wrapper for the image, I am trying to rotate a square div over let's say 45 deg. to give it a diamond like shape so actually it comes as the image is being cut in a diamond like shape.
The issue is when I rotate the div the image and other things in it also gets rotated than I have to rotate those images back let's say -45deg to bring them to original place.
This is doing above involved a lot of rotating which is almost un-necessary, plus it's really not that simple for me to get it right for images and text of different size etc.
If only I can work out something through which on the above div gets rotated and elements inside it remain like how they are it will be great.
Can anyone suggest anything please?
My markup is:
<div class="wrapper" id="01">
<a href="#">
<img src="image.gif" />
<span class="text" id="text01">Lorem Ispum </span>
</a>
</div>
CSS:
.wrapper {
-webkit-backface-visibility: hidden;
position: relative;
width: 300px;
height: 300px;
margin: 0 30px 0 0;
overflow: hidden;
float: left;
-moz-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-moz-transform-origin: center;
-webkit-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-webkit-transform-origin: center;
-o-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-o-transform-origin: center;
-ms-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-ms-transform-origin: center;
transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
transform-origin: center;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=-0.5,M21=-0.5,M12=0.5,M22=-0.5,SizingMethod='auto expand')";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.5,M21=-0.5,M12=0.5,M22=-0.5,SizingMethod='auto expand');
cursor: pointer;
}
.wrapper img {
width: 700px;
margin: -10px 0 0 -245px;
-moz-transform: rotate(135deg);
-moz-transform-origin: center;
-webkit-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
-webkit-transform-origin: center;
-o-transform-origin: center;
-ms-transform-origin: center;
transform: matrix(-0,-0,0,-0,0,0);
transform-origin: center;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=-0,M21=-0,M12=0,M22=-0,SizingMethod='auto expand')";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0,M21=-0,M12=0,M22=-0,SizingMethod='auto expand');
}
span.text {
background-color: rgba(255,255,255,0.7);
-webkit-transform: rotate(180deg);
margin: -475px 0 0 -1px;
float: left;
width: 296px;
height: 42%;
z-index: 100;
position: relative;
padding: 4px;
display: none;
font-size: 1.2em;
}