TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Full CSS3 Lightbox - Absolutely no JavaScript

252 pointsby js4allover 14 years ago

21 comments

deaxonover 14 years ago
I've been tweeting this today but I think it could be useful to repeat it here: my CSS demos are only experiments. The goal is to test all those new possibilities, show the power of CSS3 and, basically, having fun. They aren't intended to be used in production and actually you shouldn't. Most of them are not accessible and not cross browser…
评论 #1884351 未加载
评论 #1885372 未加载
aw3c2over 14 years ago
So I will get lightboxed even with my no-javascript browsing habits? I liked that most sites simply serve the direct image url to me. Lightbox is an annoying eye-candy.
评论 #1884356 未加载
评论 #1883935 未加载
评论 #1885880 未加载
评论 #1885695 未加载
评论 #1884086 未加载
krmmalikover 14 years ago
Dont like how when i press the back button i get a history of pictures i have viewed. If i am at liberty to choose whichever picture i want then i dont need the back button to preserve my selection history. When i click back, i want to go BACK to the site i just came from.<p>I assume this isnt some bug or some flaw, and that it can probably be coded to behave differently, but as things stand that would prevent me from using this particular lightbox.
评论 #1884457 未加载
评论 #1884359 未加载
jluxenbergover 14 years ago
Is it just me or is the Lighbox effect really annoying? What's wrong with middle-clicking an image and having it open in a new tab?
评论 #1883695 未加载
评论 #1883742 未加载
评论 #1884267 未加载
评论 #1883749 未加载
cmerover 14 years ago
Nice! It breaks the back button however...
评论 #1883600 未加载
评论 #1884251 未加载
评论 #1883560 未加载
Semiapiesover 14 years ago
Neat that you can do that. Not a technique that I'd ever want to use.
评论 #1883611 未加载
评论 #1883568 未加载
bradlaneover 14 years ago
Works great in Chrome; Firefox has a border around each pic, since they're links.<p>Of course, it's horribly, horribly broken in IE. Then again, that goes without saying ;)
评论 #1883718 未加载
krosaenover 14 years ago
Interesting to see this is possible, but this is beyond what I would want to use css for, how far will "look ma! no javascript!" go? Seing the logic in a jquery click handler seems at least as readable / maintainable as a bunch of css rules for the same reason I prefer to have more logic in java in android applications than in various xml layout and manifest files.
评论 #1883869 未加载
评论 #1884057 未加载
IChrisIover 14 years ago
This is pretty cool. Suggestions:<p><pre><code> - respect my back button [1] - allow me to click outside the picture or press esc to close the lightbox - allow middle-click to open the image directly </code></pre> [1] We can argue about transitions and correct behavior all day, but this implementation is different from other lightboxes I've seen, and thus it is "broken" to me.
评论 #1885650 未加载
blhackover 14 years ago
Out of curiosity, what is the point of a "light box"? I tend to open lots of images into new tabs while I'm reading articles, and it's <i>really</i> annoying to have the rest of the article go black when I do.
评论 #1884148 未加载
评论 #1884143 未加载
评论 #1884346 未加载
tormeover 14 years ago
Very neat, I checked out the other stuff you've got on there and it's pretty sweet.<p>Seems like a lot of people have missed the point that this is just a hack to see if a light box in JUST CSS and HTML could be made. Because theres no JS or actual logic, this demo just leverages the browser to maintain the state. It's a necessary side effect that the back buttons behave this way, and it <i>could</i> be coded to behave differently, but that would defeat the purpose of the exercise.
TamDenholmover 14 years ago
Works beautifully on the iPad. Very nice work.
dpatruover 14 years ago
It's done by using the :target selector. Targeted images are lightboxed. There is a link in the lightbox that resets the target to dismiss the lightbox. Crudely:<p>css: a.lb:target {display:block; text-align:center;} a.lb {display:none;}<p>html: &#60;a href="#img"&#62;show image&#60;/a&#62; &#60;a class="lb" href="#" id="img"&#62;&#60;img src="image.jpg"&#62;&#60;/a&#62;
EGFover 14 years ago
This is actually quite nice because it allows permalinks to the lightbox items. This makes for a rough browsing experience if you need to go back, but I like the detail that lets you link somewhere that someone can actually find in the future vs. "go to this page, then click here, etc...."
dmixover 14 years ago
Looks great. Does this work cross-browser? (besides the transition effect)<p>Also, is there any documentation/github repos?
评论 #1883699 未加载
评论 #1883575 未加载
评论 #1883673 未加载
评论 #1883581 未加载
unicornhornover 14 years ago
Does anybody know of a minimalist JS variant? There are so many JS lightbox versions I don't even know where to start. I need something super simple.
bradlaneover 14 years ago
If you go up a directory, there are some other neat things in CSS:<p><a href="http://playground.deaxon.com/css/" rel="nofollow">http://playground.deaxon.com/css/</a>
评论 #1883659 未加载
lurchpopover 14 years ago
kind of annoyed me there was no explanation.<p>- 2nd UL list is opacity:0 - :target psuedoclass applies to element whose id is in the url - targeted element has opacity:1
DjDarkmanover 14 years ago
The problem is that not all browsers support CSS3.
akivabambergerover 14 years ago
can someone post a screenshot of this in IE6
评论 #1884075 未加载
jon_hendryover 14 years ago
Slow, like all lightbox implementations. And the flash of the background color is likely to give someone a seizure. (Ok, I'm being facetious there, but it looks jerky.)