2

I'm having this really weird issue that I have no idea what's causing it.

I have a gallery of large images, that I'm re-sizing to 620 x 250 pixels with CSS. When a user hovers over the image, I show an overlay with some text in it. I also have a bit of a blur effect on the image. There's a live working version you can take a look at here: http://snoriderswest.com/hotshots.

So, now I set the exact same thing up on another site. But on random photos, it'll produce this really strange shadow extending beyond the image. It happens to maybe 1 in 5 photos. If I change any CSS, it could happen to totally different images.

enter image description here

Also, I just realized, it only happens in Safari. Here's a jsfiddle of what's going on: (Make sure you view it in safari!) http://jsfiddle.net/y60c18fc/

It's just so unpredictable that I don't understand. What can I do?

Here's my code:

<div>
    <img src="https://assets.crowdsurge.com/datacapture/example/img/example_logo.png" class="gallery">
    <div class="overlay">
        <h2>Test!</h2>
    </div>
</div>

<div>
    <img src="https://assets.crowdsurge.com/datacapture/example/img/example_logo.png" class="gallery">
    <div class="overlay">
        <h2>Test!</h2>
    </div>
</div>

<div>
    <img src="https://assets.crowdsurge.com/datacapture/example/img/example_logo.png" class="gallery">
    <div class="overlay">
        <h2>Test!</h2>
    </div>
</div>

<div>
    <img src="https://assets.crowdsurge.com/datacapture/example/img/example_logo.png" class="gallery">
    <div class="overlay">
        <h2>Test!</h2>
    </div>
</div>


div {
  width: 620px;
  height: 250px;
  overflow: hidden;
  margin-bottom: 15px;
  position: relative;
}

div img {
  width: 100%;  
}

div:hover img {
  -webkit-filter: blur(10px);
  -moz-filter: blur(10px);
  -o-filter: blur(10px);
  -ms-filter: blur(10px);
  filter: blur(10px);
}

div .overlay {
  display: none;
  height: 100%;
  width: 100%;
  background-color: #fff;
  opacity: 0.6;
  position: absolute;
  top: 0px;
  color: #000;
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  font-weight: bold;
  font-size: 30px;
}

div:hover .overlay {
  display: block;
}
eshellborn
  • 11,031
  • 5
  • 20
  • 29

2 Answers2

3

Because blur is not a very performant css filter, you need to force hardware acceleration when applying it. Applying a 3d translate is a nifty way of forcing it.

All I did to fix your issue was add:

div:hover img {
    -webkit-transform: translate3d(0, 0, 0);
}

jsFiddle example here: http://jsfiddle.net/y60c18fc/1/

And here is a more indepth article on what is going on behind the scenes: http://blog.kaelig.fr/post/47025488367/css-filters-in-the-real-world

TheIronDeveloper
  • 3,294
  • 1
  • 18
  • 17
0

jsfiddle.net/w37jkwLx/

div:hover img - needs height:250px;

Fixes it in safari

  • But then it adds a very disgusting shadow all around, and that is certainly not what I want. – eshellborn Dec 17 '14 at 18:45
  • Oh, and another, more severe problem, is that all my photos are 620 x 378 pixels, and are being cropped down to 250 pixels high. So I can't set a height to the images or they will squish @WebsterDevelopine – eshellborn Dec 17 '14 at 18:55
  • the static height is not cool. This may be a related to this post http://stackoverflow.com/questions/21066650/safari-blurs-strange-bugs – WebsterDevelopine Dec 17 '14 at 19:03
  • What's not cool about it? And I already saw that post, and tried his suggestions, but they didn't work. – eshellborn Dec 17 '14 at 19:26