Transition rotate causes chrome to flash black screen. Is it a Chrome bug (works fine in Safari) or it can be fixed with some clever css.
div {
width:200px;
height:200px;
position:relative;
background:#ddd;
}
span {
display:inline-block;
position:absolute;
top:40px;
left:40px;
width:20px;
background:#007;
height:10px;
-webkit-transition: all .5s;
}
div:hover > span {
-webkit-transform: rotate(180deg);
}
<div>
<span></span>
</div>
Example fiddle here.
The problem with this problem is that it doesn't occur every time so you'll have to hover the gray square several times and you should see the screen blinking in black.
Tested in:
Chrome 16.0.912.75
Chrome Canary 18.0.1010.0
Works fine on:
Safari 5.1.2 (6534.52.7)
All test on Snow Leopard
You can fix this by forcing compositing to stay on by giving -webkit-transform: translate3D(0, 0, 0) to the parent of the transformed element.
div { width:200px; height:200px; position:relative; background:#ddd; -webkit-transform: translate3D(0, 0, 0)}
span { display:inline-block; position:absolute; top:40px; left:40px; width:20px; background:#007; height:10px; -webkit-transition: -webkit-transform .5s; }
div:hover > span { -webkit-transform: rotate(180deg); }
<div>
<span></span>
</div>
Check out the fiddle: http://jsfiddle.net/UHLFF/
Related
I'm having difficulty trying to get an image overlay and image zoom to appear at the same time on mouse hover. For some reason, the overlay disappears when I added the image zoom. It seems like one webkit transition cancels the other out. Either the zoom will work or the overlay will appear but not both. Any help is greatly appreciated, I've been researching for hours and can't seem to figure it out.
HTML Code:
<div class="image_wrap">
<div class="caption">
<i class="fa fa-search-plus" aria-hidden="true"></i>
<p class="heading">
Resort Website
</p>
</div>
<img src="css/images/resort.jpg" alt="resort" class="portfolio-pic">
</div>
CSS Code:
.image_wrap{
position:relative;
}
.image_wrap .caption{
position:absolute;
width:100%;
height:100%;
opacity: 0;
text-align:center
display:inline-block;
background: linear-gradient(rgba(51, 153, 170, 0.9), rgba(51, 153, 170, 0.8));
-webkit-transition:all .4s ease-in-out;
transition:all .4s ease-in-out
}
.image_wrap .caption:hover{
opacity: 1;
}
.image_wrap .caption img {
position:relative;
-webkit-transition:all .4s linear;
transition:all .4s linear;
}
.image_wrap .caption:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}
I detect two problems on your code, change this:
.image_wrap .caption:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}
For this:
.image_wrap:hover img {
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
z-index:8;
}
You can answer why. Because your image not inside .caption and you didn't declare the z-index (caption on the image).
Declare the z-index on caption too.
.image_wrap:hover .caption {
opacity: 1;
z-index:9999;
}
Here is the link for jsfiddle where I test our code: link
I have developed an CSS and HTML code to create some kind of accordion multi-banner. I'm not using javascript at all.
Every thing works fine,except for I issue I can not resolve:
Start point is the first image "expanded"
If you hover over some other image, the former hovered one srinks,and the current also expand. Remainig ones accomodate their witdh
PROBLEM: if you hover fast from left to rigth to the last image you come to a point where you can over a greyed on (wrapper background) and all iamges remain then collapsed.
A must should be that,always, no matter what, there's at least one image expanded to show let's say an ad,product to choose...
How can I resolve that? The reason I'm not using width:auto is that it currently doesn't make any transitions with that value set.
CODE at http://jsfiddle.net/7NR4Y/
<style type="text/css">
#wrapper div.sector {
width:50px;
height:250px;
background-position:top center;
background-repeat:no-repeat;
float:left;
max-width:300px;
opacity:0.5;
overflow:hidden;
-webkit-transition:all 1s ease-out; /* Chrome y Safari */
-o-transition:all 1s ease-out; /* Opera */
-moz-transition:all 1s ease-out; /* Mozilla Firefox */
-ms-transition:all 1s ease-out; /* Internet Explorer */
transition:all 1s ease-out; /* W3C */
}
#wrapper #first{
width:300px;
max-width:300px;
min-width:50px;
opacity:1;
}
#wrapper:hover div.sector{
width:50px;
max-width:100%;
opacity:0.5;
}
#wrapper:hover #first{
width:50px;
max-width:100%;
}
#wrapper div.sector:hover{
width:300px !important;
opacity:1;
}
</style>
<body>
<div id="wrapper" style="width:500px; height:250px; background-color:#CCC; overflow:hidden; position:relative;">
<div id="first" class="sector" title="Imagen 1"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRTpTF_3Pjjnsum_miN1hicvsPb-44qUm4Qban2_MfzEHevwK0_" /></div>
<div class="sector" title="Imagen 2"><img src="http://1.bp.blogspot.com/-dazqpbQnahc/UaxhFz6mwgI/AAAAAAAAGJQ/pVhtFcqEBiY/s640/Ideal-landscape.jpg" /></div>
<div class="sector" title="Imagen 3"><img src="http://2.bp.blogspot.com/-XegWV6RbUmg/UKIA7m7XgDI/AAAAAAAAAtA/6yQKXMkTjmA/s640/village-vector-the-dock-pixels-tagged-beach-landscape-512305.jpg" /></div>
<div class="sector" title="Imagen 4"><img src="http://i.telegraph.co.uk/multimedia/archive/01842/landscape-rainbow_1842437i.jpg" /></div>
<div class="sector" title="Imagen 5"><img src="http://c.dryicons.com/files/graphics_previews/sunset_landscape.jpg" /></div>
</div>
I have added the following to your CSS
a:last-child div.sector {
position: relative;
overflow: visible !important;
}
a:last-child div.sector:after {
content: "";
position: absolute;
left: 100%;
top: 0px;
height: 100%;
width: 100px;
background-color: green;
}
This creates a pseudo element after the last div of your series.
This pseudo will receive the hover state and transmit it to the element. This, way, even if the cursor goes in the zone of the wrapper that gets exposed sometimes, it will still get it selected.
I have it green so that you can se what is happening, of course in production make it transparent.
fiddle
Disregard all the previous answer !
All you need is
a:last-child div.sector {
overflow: visible !important;
}
fiddle 2
In my demo link, kindly hover the image section, see the image exceed issue.
Over flow hidden and border radius not working when i use css transition scale effects in chrome browser.
It's working fine on Mozilla Firefox, but chrome is not working correctly, i give overflow hidden & border radius but the hover image is exceed on image area.
How to solve this problem. I tried lot's of time, but i can't fix & can't find the correct solution.
kindly click the demo
http://tcxsandbox.com/stack-overflow/
And also check the 2nd comment, I have placed the fiddle link.
You must declare the parent element in relative position and child with absolute , after use z-index and declare parent (with border-radius and overflow hidden) before child . example:
<div class="parent">
<img class="child" src="yourimage.jpg" />
</div>
<style>
.parent{
/*must declare border radius and z-index*/
position: relative;
border-radius:100px;
z-index:5;
}
.parent img{ /*Child element*/
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out ;
transition: all .3s ease-in-out;
-webkit-transform: scale(1,1) ;
-moz-transform: scale(1,1);
transform: scale(1,1);
z-index:4; /*here's where magic happens*/
}
.parent img:hover{
img{
-webkit-transform: scale(1.1,1.1) ;
-moz-transform: scale(1.1,1.1);
-o-transform: scale(1.1,1.1);
-ms-transform: scale(1.1,1.1);
}
}
</style>
this should work.
NOTE: i recommend declare border radius for both elements (parent and child ) for prevent crossbrowsing problems .
consider below code:
.box-main-img {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
}
Add border-radius to your box-main-img class
.box-main-img {
float: left;
width: 100%;
overflow: hidden;
height: 143px;
border-radius: 5px;
}
FIDDLE
When I apply transition in Chrome(24.0.1312.57) on hover it does not update background-color on mouse out. See this fiddle: http://jsfiddle.net/WKVJ9/
Here is the code:
.transition{
-webkit-transition: all 500ms ease-in-out;
}
.wrapper{
width:200px;
height:200px;
display:block;
background-color:cyan;
position:relative;
}
.hoverme{
border-radius:90px;
display: block;
width:50px;
height:50px;
top:50px;
right:-90px;
position:absolute;
-webkit-transform: rotate(-45deg);
}
.wrapper:hover .hoverme{
-webkit-transform: rotate(0deg);
right:0;
}
.hoverme:hover{
background-color:red;
}
and html:
<div class="wrapper">
<div class="hoverme transition">
Hover me
</div>
</div>
If you hover .wrapper and .hoverme and then quickly move mouse away from this box the .hoverme element will only animate rotation and position.
On the site I am working on it does not even refresh hover state so when the animation is finished and the background stays with :hover background-color... Which for some reason I cannot reproduce here
Is it possible to make the background animate?
This is happening because of position:absolute in .hoverme
try changing it to position:relative add margin-left:150px; (or required) to correct position of .hoverme ... like this:
.hoverme{
border-radius:90px;
display: block;
width:50px;
height:50px;
top:50px;
right:-90px;
position:relative;
margin-left:150px;
-webkit-transform: rotate(-45deg);
}
check it in action here: http://jsfiddle.net/WKVJ9/1/
I have frame styles for the image:
.frame {
background:#efefef;
border:1px solid #f6f6f6;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.4); /* #todo Old Browsers Fix */
margin-bottom:15px;
padding:4px;
}
in one place of the project I work on, I have following HTML code:
<a href="#" class="preview">
<img class="frame" src="http://placehold.it/288x159" alt="" />
</a>
Basically, I want to change file opacity on mouseover and add a background (preview icon) to the link. I have following code:
.preview img.frame {
margin:0;
position:relative;
}
.preview:hover {
background:url('../img/icon_zoom.png') center center no-repeat;
display:inline-block;
z-index:40;
}
.preview img { /* #todo Add different browsers rules */
opacity: 1;
/*moz-transition-property:opacity;
-moz-transition-timing-function:ease-out;
-moz-transition-duration:500ms;*/
-moz-transition:opacity 1s ease-in-out;
}
.preview:hover img {
opacity:.5;
-moz-transition:opacity 1s ease-in-out;
/*-moz-transition-property:opacity;
-moz-transition-duration:500ms;
-moz-transition-timing-function:ease-out;*/
display:block;
position:relative;
z-index:-1;
}
However I faced few issues:
- how can I show background only for image body (currently it's also being displayed on the border)?
- why opacity is not being changed in Chrome?
jsFiddle added. As you may see, it works in FF, but not in Chrome.
The problem appears to be that you're changing the display to inline-block. Take it out, it should have the same functionality and work just fine.
Changing a couple other things seems to have it working as you intended. http://jsfiddle.net/minitech/v2vtw/2/