Image inside a rotating image - html

I have two images:one is supposed to be like a border and it would rotate on hover,the other one is supposed to be inside the first image that rotates.How can i put the second image inside the first?Here is my code and jsfiddle...
<div class="col-xs-4" style="text-align:center;margin-top:20px;background:black;">
<img class="img-responsive rotate" src="http://s21.postimg.org/s70s6ioyb/Okvir_rotirajuci.png" style="display:inline-block;"/>
<img class="img-responsive" src="http://s23.postimg.org/d0uos0jvb/E_mail.png" style="display:inline-block;"/>
</div>
My css...
.rotate{
-moz-transition: all 0.6s ease-in-out;
-webkit-transition: all 0.6s ease-in-out;
-o-transition: all 0.6s ease-in-out;
-ms-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
.rotate:hover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
JSFIDDLE

I had to use a couple of nested elements to achieve all three goals:
Spinning border and envelope icon overlap and align together.
Image pair is centered horizontally.
Image pair size is responsive.
Explanation
The element div.image_wrap is a centered child of div.container that provides a container for both images. It's width is 100% of div.container, but no more than 42px (the width of your images).
The element div.image_height_prop gives div.image_wrap (and therefore div.container) height. Since the images inside are positioned absolutely (so that they overlap), they have no height and will not prop open their container. div.image_height_prop has padding-top set to 100% of its parents width, essentially making a responsive square strut.
The images are positioned absolutely on top of one another, with the "border" last in the DOM so that it will be on top of the stacking order (for hover).
HTML
<div class="col-xs-4 container">
<div class="image_wrap">
<div class="image_height_prop">
<img class="icon" src="http://s23.postimg.org/d0uos0jvb/E_mail.png" />
<img class="rotate" src="http://s27.postimg.org/x4d8qxe73/square.png" />
</div>
</div>
</div>
CSS
div.container {
text-align:center;
background:black;
margin-top:20px;
}
div.image_wrap {
display:inline-block;
max-width:42px;
width:100%;
}
div.image_height_prop {
position:relative;
width:100%;
padding-top:100%;
height:0;
}
div.image_wrap img {
position:absolute;
top:0;
left:0;
width:100%;
}
img.rotate {
-moz-transition: all 0.6s ease-in-out;
-webkit-transition: all 0.6s ease-in-out;
-o-transition: all 0.6s ease-in-out;
-ms-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
img.rotate:hover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
Working Example
As mentioned by #chiliNUT, the box in the "border" image is off-center. I centered the image and and re-uploaded it. As an alternative, you could add a 1px left margin to the "envelope" image to adjust for the box being off-center.
img.rotate {
margin-left:1px;
}
An example of that

This will do it:
Wrap the images in an inline-block div.
Remove the inline-block style from both images.
Make the first image position:absolute, which will impose it onto the second image.
Leave the second image's style alone, the img element defaults to display:inline which is what we want.
See my update to your fiddle
http://jsfiddle.net/T8Pjh/17/
<div class="col-xs-4" style="text-align:center;margin-top:20px;background:black;position:relative;">
<div style=display:inline-block;>
<img class="img-responsive rotate" src="http://s21.postimg.org/s70s6ioyb/Okvir_rotirajuci.png" style="position:absolute;" />
<img class="img-responsive" src="http://s23.postimg.org/d0uos0jvb/E_mail.png" />
</div>
</div>

Related

CSS hover event, Animation wont run

I have a container that holds image holder and text holder.
I can set it so that on hover the image scales and the same for the text.
YET when I try so set the image holder hover to scale the image and a secondary action to scale the text, hover just doesnt do the animation .
<div class="container">
<div class="imageholder"><img></div>
<div class="textholder"><text></div>
</div>
CSS
.imageholder:hover .textholder{
transform: translatey(100%);
transform: scale(1.1);
transition: .5s ease;
}
heii, you can change your code like this :
.imageholder:hover, .textholder:hover{
transform: translatey(100%);
transform: scale(1.1);
transition: .5s ease;
}
<div class="container">
<div class="imageholder">this is image</div>
<br/>
<div class="textholder">this is a text</div>
</div>
You need to add coma in your css like this:
.imageholder:hover, .textholder:hover{
transform: translatey(100%);
transform: scale(1.1);
transition: .5s ease;
}

HTML/CSS - Images overlapping each other only on one side with transform

while i was creating a website i stepped into something unexpected.
https://jsfiddle.net/m9qgxeke/3/
As you can see after an image has expanded it returns to it's original size, but the div after jumps over it. I tried everything i could think of, but nothing worked. Is there a way to prevent this to happen?
HTML
<div class="img-gr transition">
<img src="http://lorempixel.com/400/200/city" alt="Placeholder image" class="img-responsive" title="Lavoro 1">
</div>
<div class="img-gr transition">
<img src="http://lorempixel.com/400/200/city" alt="Placeholder image" class="img-responsive" title="Lavoro 2">
</div>
<div class="img-gr transition">
<img src="http://lorempixel.com/400/200/city" alt="Placeholder image" class="img-responsive" title="Lavoro 3">
</div>
CSS
.transition img {
display: block;
transition: transform .2s ease;
-moz-transition: transform .2s ease;
-webkit-transition: transform .2s ease;
-ms-transition: transform .2s ease;
-o-transition: transform .2s ease;
position: relative;
z-index: 2;
}
.transition img:hover, .transition img:active {
transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-webkit-transform: scale(1.1);
z-index: 10;
}
Simply remove the position: relative; from .transition img
This works for me in Chrome: https://jsfiddle.net/m9qgxeke/8/
The trick is to make a transition on the z-index-property that starts after the 0.2 seconds (when the image is back in place):
transition: transform .2s ease, z-index 0.2s 0.2s;
But this would apply to the "in-transition" (smaller image to bigger image) as well, which we don't want, so we have to disable the z-index-transition for the "in-transition" with the active-pseudo-selector:
.transition img:active {
transition: transform .2s ease, z-index 0s;
}
Code is shortened for clarity.
Edit: bumpys solution is much more simple and recommendable, my approach also works for position: relative-elements, in case this is an requirement (which I don't suspect for simple images).

Issue related to deactivating hover effect in CSS

I have following class in CSS file :
.grid-container-columns:hover .column-container-wrap, .grid-container-columns.active .column-container-wrap {
height: 400px;
-webkit-transition: height 0s;
-moz-transition: height 0s;
-o-transition: height 0s;
transition: height 0s; }
/* line 369, ../scss/_general.scss */
.grid-container-columns:hover .column-container, .grid-container-columns.active .column-container {
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0); }
and following HTML
<div id="divColumns" class="grid-container-columns">
<div class="column-btn">
<span class="fa fa-th-list"></span> Kolommen
</div>
<div class="column-container-wrap">
<div class="column-container"></div>
</div>
</div>
When I hover in the above div(having id="divColumns"), content of the div displays. I want to deactivate the hover effect and don't want to display the content but don't want to remove CSS class because its used in other pages..
I have tried following in my HTML page:
$(".grid-container-columns").hover(function (event)
{
event.preventDefault();
})
But it doesn't working. How can i stop displaying content of div in hover effect??
Just exclude that div using its id in your class. This can be done by the CSS negation selector :not().
Instead of:
.grid-container-columns:hover { ...
Do this:
.grid-container-columns:not(#divColumns):hover { ...
Demo Fiddle: http://jsfiddle.net/abhitalks/ujjamg9y/
Notice in the demo that the first div doesn't respond to hover, but the second one does.

center aligning several crossfade images

I'm trying to center align several crossfade icons within a widget. So far, I've only managed to align them either left or right. If I try to do anything else, it just stacks each icon vertically. Here's the CSS:
.icon {
float:left;
position:relative;
height:32px;
width:32px;
padding:4px;
}
.icon img {
position:absolute;
left:0;
opacity: 1;
-webkit-transition: opacity .3s ease-in-out;
-moz-transition: opacity .3s ease-in-out;
-o-transition: opacity .3s ease-in-out;
-ms-transition: opacity .3s ease-in-out;
transition: opacity .3s ease-in-out;
}
.icon img.top:hover {
opacity:0;
}
And the HTML for one icon:
<div class="icon">
<img src="http://i516.photobucket.com/albums/u322/_manda_rose_/BLOG/Syrup%20Misc/Social%20Icons/twitter-1.png" class="bottom" />
<img src="http://i516.photobucket.com/albums/u322/_manda_rose_/BLOG/Syrup%20Misc/Social%20Icons/twitter.png" class="top" />
</div>
I'm trying to do it with five icons, but can't figure it out. Seems to be a problem with how the crossfade effect stacks the images.
Here it is on JFiddle.
Try surrounding them with a 100% width div, removing float:left, and adding display:inline-block
http://jsfiddle.net/3on0x2Ly/2/
You can do that with one more div tag, which will wrap the icon. First you have to remove the float: left property of the class .icon.
Now one of the ways is to set the .icon class to inline block and the new div tag, which wrap them, you have to give it a text-align property to center. And that will center the each icons.
Here is the code - http://jsfiddle.net/syrup/3on0x2Ly/1/

problems with hiding div on hover

For a new webdesign I made two 50% width div's that slide over on hover. When hovering on the left 'slide' div, I want the right 'logo' div to hide (display:none) and vice versa, but it just won't work. What am I missing here? Any help would be much appreciated!
body {
background:black;
}
.slide {
position:absolute;
top:0;
bottom:0;
width:50%;
-webkit-transform:skew(-15deg);
-moz-transform:skew(-15deg);
-ms-transform:skew(-15deg);
-o-transform:skew(-15deg);
transform:skew(-15deg);
z-index:2;
}
.slide:hover {
width:60%;
z-index:80;
}
.slide#left {
left:0;
}
.slide#right {
right:0;
}
.wrap {
width:100%;
height:100%;
position:absolute;
overflow:hidden;
z-index:2;
}
.inner {
width:100%;
height:100%;
-webkit-transform:skew(15deg) scale(1.5);
-moz-transform:skew(15deg) scale(1.5);
-ms-transform:skew(15deg) scale(1.5);
-0-transform:skew(15deg) scale(1.5);
transform:skew(15deg) scale(1.5);
opacity:0.6;
position:absolute;
}
.slide:hover .inner {
opacity:0.9;
}
.inner#left {
background:url(//savado.nl/new/key.jpg) no-repeat center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-ms-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.inner#right {
background:url(//savado.nl/new/code2.jpg) no-repeat center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-ms-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.inner#left:hover .logo#right {
display:none;
}
.inner#right:hover .logo#left {
display:none;
}
.slide .logo {
position:absolute;
z-index:99;
top:50%;
height:30%;
}
.logo img {
height:100%;
}
.logo#left {
right:0;
-webkit-transform:translateX(50%) translateY(-50%) skew(15deg);
-moz-transform:translateX(50%) translateY(-50%) skew(15deg);
-ms-transform:translateX(50%) translateY(-50%) skew(15deg);
-o-transform:translateX(50%) translateY(-50%) skew(15deg);
transform:translateX(50%) translateY(-50%) skew(15deg);
}
.logo#right {
left:0;
-webkit-transform:translateX(-50%) translateY(-50%) skew(15deg);
-moz-transform:translateX(-50%) translateY(-50%) skew(15deg);
-ms-transform:translateX(-50%) translateY(-50%) skew(15deg);
-o-transform:translateX(-50%) translateY(-50%) skew(15deg);
transform:translateX(-50%) translateY(-50%) skew(15deg);
}
div {
-webkit-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-moz-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-ms-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-o-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
}
<div class='slide' id='right'>
<div class='wrap'>
<div class='inner' id='right'></div>
</div>
<div class='logo' id='right'>
<img src='//savado.nl/new/logo.png' />
</div>
</div>
<div class='slide' id='left'>
<div class='wrap'>
<div class='inner' id='left'></div>
</div>
<div class='logo' id='left'>
<img src='//savado.nl/new/logo.png' />
</div>
</div>
And here is the [JSFIDDLE][1]!
Thanks in advance!
[1]: http://jsfiddle.net/NZXeT/
That is because your CSS
.inner#left:hover .logo#right {
display:none;
}
.inner#right:hover .logo#left {
display:none;
}
Will never be valid, there is no .logo#right INSIDE your .inner#left:hover element, it only contains a .logo#left. The same with the other.
You will have to re-think your design for this to work, I do not see why you need two logo's, why not just have one logo that slides one side or the other? Why have to hide them?
So your first issue is that you have multiple elements with the same ID. That's going to make things confusing (and invalid), so stick with unique IDs.
Second, CSS has the limitation of only being able to affect the element in the rule, siblings after that element, or children of that element. This means that if you want to stick with pure CSS you're going to need to get slightly hacky.
If you want to use javascript/jQuery, it's basically a one-liner fix.
If you want to stick with pure HTML+CSS you can use the sibling selector ~ to match the other slide. Try this:
.slide#right:hover ~ .slide#left {display: none;}
You'll see the left side hide when you hover the right just like intended! However, doing the opposite won't work :( This is because the left element is after the right in the markup. However, you can "cheat" and add a hidden "trigger" over the left side. If you add an element before .slide#right that is exactly the same size and shape of .slide#left, then add the same rule as I have here but replace #right with #lefttrigger it should work.
Does that make sense?