0

I am building a portfolio website that uses only CSS3 to display a grid and filter out thumbnail images.

You can see what I've done here.

I got the filter functionality to work by using this tutorial and using the :checked pseudo class.

The grid is made using css3 columns to create a seamless responsive photo grid. I used Chris Coyier's example.

Everything works in most modern browsers, but it breaks in mobile safari for the iPhone. Upon further testing, it seems to also break in the Sleipnir browser for iPhone, but WORKS in the Opera Mini browser. Also, it does the exact same thing on iOS Safari for iPad.

Also important to note that the bug does not occur because of the small browser width. It works fine at small browser widths on Mac OSX Safari 5.

Now on to the problem: When viewed on the iPhone, everything looks great until you click on a filter label (web design, illustration, typefaces, identity, and print). After clicking on a label, nothing is suppose to move. Only the opacities of the thumbnails change. After clicking "Identity" for example, the right column breaks and the images seem to disappear. Now, click "All" and the images appear back into the right column and everything looks the way it did when you first visit the page.

The images seem to fall under the first column of images, below the footer and out of sight.

Here is what it's suppose to look like after clicking "Identity" — http://cl.ly/1M3F1t1N410s150h1o40

Here is what it actually looks like right now — http://cl.ly/0r1v0Z2c1f0I2U0X0T3m

UPDATE: Removing list-style: none; from my CSS seems to improve it a lot. I have no idea why. Still doesn't work perfectly though. Some of the thumbnails are still disappearing. Will work on it some more.

UPDATE 2: I tested the site on two android tablets running the native browser. It seems to do the same thing on android. This is really annoying since it only happens on webkit (i think) mobile browsers. Maybe this has something to do with labels/inputs. That is the only thing I can think of that is different about mobile browsers. I had to input some javascript so that iOS safari would allow touch events on labels. By default, iOS doesn't let you touch a label in order to select the input (i'm using hidden radio buttons). I don't know why that would move image around the page. maybe is has to do with the zoom-on-input-touch feature?

UPDATE 3: Works on firefox mobile developer tools found here: http://www.mozilla.org/en-US/mobile/. This leads me to believe this is definitely a mobile webkit problem, not just iOS.

If you are interested, here is the code I am using for :checked pseudo class thumbnail filtering.

.ff-container input{
display: none;
}

.ff-items li img{
display: block;
}

.clr {
clear:both;
}

.ff-items li{
opacity: 0;
-webkit-transition: opacity 0.2s ease-in-out;
        transition: opacity 0.2s ease-in-out;   
}

.ff-container input.ff-selector-type-all:checked ~ .ff-items li,
.ff-container input.ff-selector-type-1:checked ~ .ff-items .ff-item-type-1,
.ff-container input.ff-selector-type-2:checked ~ .ff-items .ff-item-type-2,
.ff-container input.ff-selector-type-3:checked ~ .ff-items .ff-item-type-3,
.ff-container input.ff-selector-type-4:checked ~ .ff-items .ff-item-type-4,
.ff-container input.ff-selector-type-5:checked ~ .ff-items .ff-item-type-5{
opacity: 1;
}

.ff-container input.ff-selector-type-1:checked ~ .ff-items li:not(.ff-item-type-1),
.ff-container input.ff-selector-type-2:checked ~ .ff-items li:not(.ff-item-type-2),
.ff-container input.ff-selector-type-3:checked ~ .ff-items li:not(.ff-item-type-3),
.ff-container input.ff-selector-type-4:checked ~ .ff-items li:not(.ff-item-type-4),
.ff-container input.ff-selector-type-5:checked ~ .ff-items li:not(.ff-item-type-5){
opacity: 0.1;
}

Small section of HTML : <li class="ff-item-type-1">
<a href="projects/emily-patridge/">
<img src="images/em_c.jpg" alt="Emily Patridge Website" /> </a>
</li>

davecave
  • 4,698
  • 6
  • 26
  • 32
  • 1
    A friendly reminder to fill in the rest of the vendor prefixes where possible once you're done with your code, so other vendors don't feel left out :) – BoltClock Feb 27 '12 at 20:06
  • Not sure what exactly is going on - the thumbnails on the right side actually fall to the bottom, underneath the thumbnails on the left, rather than just disappearing altogether. Also, the thumbnails return to their correct positions when I rotate my iPhone. – BoltClock Feb 27 '12 at 20:16
  • You are correct. They fall underneath the left column of thumbnails. It seems they go below the footer. – davecave Feb 27 '12 at 21:28
  • Updated my question. I tested it on iPad and it doesn't work either. It seems to only affect iOS safari and other mobile browsers running similar code .Maybe it's webkit? – davecave Feb 28 '12 at 03:01
  • Can someone test [http://test.davewhitley.com/not-wp/static_folder/index.php] (my site) with an android phone and see if it's just iOS Safari? – davecave Feb 28 '12 at 22:42
  • Updated my question. Removing `list-style: none;` from my CSS seems to help some. – davecave Mar 01 '12 at 20:03

2 Answers2

0

OK... Short answer is that I got it working by eliminating css-columns. I created the grid using inline-block instead, and made it seamless by using vertical-align:middle. You could probably make the grid using floats as well.

Up and running here: http://test.davewhitley.com/not-wp/debug/index.php

As far as I can tell, css-columns + css opacity filtering causes a really obscure bug in iOS. Funny that it's only crapping out in iOS... I feel like no one is ever gonna come across this bug again because it's so obscure.

I would love to break it down one day and submit the bug... but I have only heard of submitting to Safari, not iOS Safari.

davecave
  • 4,698
  • 6
  • 26
  • 32
-1

It's because :checked is only supported in Opera browsers.

See here for more infomation.

ACarter
  • 5,688
  • 9
  • 39
  • 56
  • 1
    Enough has been said about W3Schools, but W3Schools is genuinely flat-out wrong (or out of the loop) here. If it isn't supported on WebKit browsers, it can't possibly work on Safari on a Mac as pointed out. – BoltClock Feb 27 '12 at 20:17
  • Really? I've never experienced them being wrong before. But yes, you are right about it being seen in Safari. – ACarter Feb 27 '12 at 20:25
  • 1
    Well, it's most probably out of date - `:checked` already has decent support across the latest versions of all major browsers. – BoltClock Feb 27 '12 at 20:27
  • I'm most perplexed by why it works on desktop Safari and not mobile Safari. – davecave Feb 27 '12 at 21:32
  • I don't think the problem is a support issue of the `:checked` class. I went through the tests [here](http://bit.ly/woza3g) on my iPhone with success, so iOS Safari seems to support the pseudo class to some degree. – davecave Feb 27 '12 at 21:58