TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Building a Magical 3D Button with Vanilla HTML/CSS

136 点作者 joshwcomeau大约 4 年前

16 条评论

stevebmark大约 4 年前
I really like the look and feel of this button.<p>Flat design is a poison. It&#x27;s an accessibility nightmare especially for older users. In a flat product, nothing and everything looks like a button, so nothing and everything looks clickable. Humans obviously use 3D spatial visual queues to process the world around us. Taking that away and removing references to real world items was something Jony Ive could have only poisoned the world with after Steve Jobs died. No hero worship for Jobs, but he led the way in understanding beautiful skeuomorphic design.<p>Apple has started introducing drop shadows and gradients and hinting at 3D elements, such as the new Messages icon on MacOS. The pendulum will swing back, not soon enough.
评论 #26640673 未加载
评论 #26640173 未加载
_carbyau_大约 4 年前
I am not a fan over super flatness and hence I appreciate a fake-3D button.<p>But in the same way that many great computer games ALSO don&#x27;t try for ultra-realism, I don&#x27;t think it needs to model the real world as much as it does.<p>Things I&#x27;d do without:<p>- rising on hover. Colour change is enough acknowledgement.<p>- shadow. Having the two coloured layers is enough.<p>- spring-like overshoot behaviour. Simple down+up is fine.<p>But it is always cool to see a nicely written &quot;I want to achieve this; this is how&quot; article. +1 to author.
cosmotic大约 4 年前
Despite the visual appeal, the jiggle hover and push effect of the button significantly reduces my confidence and satisfaction when pushing the button.
评论 #26640180 未加载
mattlondon大约 4 年前
Didn&#x27;t work consistently on Firefox on Android. It would miss taps, sometimes it would get stuck &quot;down&quot;.
chrismorgan大约 4 年前
&gt; <i>Why not use box-shadow or border? Those properties are</i> super <i>expensive to animate. If we want a buttery-smooth transition on the button, we&#x27;ll have way more success with this strategy.</i><p>Border I can understand, because it affects layout (though if you make balanced changes to top&#x2F;bottom widths, admittedly a bit harder than it may seem at first if you use an easing curve, it would be <i>possible</i> for the engine to recognise it and skip layout, though I have no idea if they do).<p>But box-shadow? Huh? Why would that be expensive to animate (let alone <i>super</i> expensive)? It doesn’t affect layout, it’s just painting.<p>Now admittedly my perspective on this sort of thing has been skewed by using Firefox, where WebRender completely throws out the old performance guidelines (and box-shadow is certainly not expensive to animate, and the multiple-element version will certainly be a negligible smidgeon less efficient), but I thought and would expect that even in the old inferior rendering world that all the other browsers inhabit box-shadow is not expensive to animate provided you’ve used the standard hacks to GPU-accelerate the element’s rendering.<p>Certainly I’ve never observed any smoothness issues on animations of box-shadow.<p>I’m interested in whether I’ve forgotten something here, or whether Josh really is overstepping in his description.
评论 #26644485 未加载
dsun180大约 4 年前
You should add &quot;user-select: none;&quot; so it looks better on touch devices without the blue selection box.
评论 #26639767 未加载
评论 #26639827 未加载
chad-autry大约 4 年前
Touch screen tap works, but laptop track pad &#x27;tap&#x27; does not count as a click on the button.
Waterluvian大约 4 年前
I like the button except it flickers when I press it and I accidentally selected the buttons text which just completely kills my vibe.<p>Selectable text is one of the best parts of the Web. But a whole lot more UI elements could be made unselectable by default.
stuaxo大约 4 年前
Your lego guy that pops out asking to share something you&#x27;ve been working on is a bit annoying - I&#x27;m already half way through reading one article.<p>OK, I&#x27;m not now, I got distracted to come here and comment.
评论 #26646636 未加载
maxekman大约 4 年前
I for sure could not stop clicking! :)
评论 #26639671 未加载
superkuh大约 4 年前
It&#x27;d be nice to see an example of the button being a hyperlink to see if I could right click and open in new window or use mouse gestures with it. I tried just putting a &lt;a href=&quot;&quot;&gt;&lt;&#x2F;a&gt; within the class=&quot;FinalButton__Contents-shq40f-3 eFOYWi span and the link was non-functional in all GUI browsers I tried. Why bother not making it from JS when you have to use JS to actually use the button?<p>This button also does not render at all in browsers older than a handful of years. This might be good for a fun, hip project or something commercial where the customer base is small and well characterized. But if it&#x27;s a site you where expect all kinds of people from all walks of life this isn&#x27;t going to cover it.<p>The next step should be to implement it in a way that falls back safely so the function is always accessible even if the fancy animation isn&#x27;t.
评论 #26640756 未加载
gherkinnn大约 4 年前
Gorgeous. The button and the explanation.
dinhvle大约 4 年前
I don&#x27;t know why, but it feels a bit uncanny for my eyes, felt off but don&#x27;t know what it is.
learningwebdev大约 4 年前
Now that is a beautifully designed website.
dmitriid大约 4 年前
&gt; Why not use box-shadow or border? Those properties are super expensive to animate.<p>The web is the main obstacle to having nice things on the web.
评论 #26641586 未加载
jmann99999大约 4 年前
Scott Forstall, is this really you? :-) [1]<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Skeuomorph" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Skeuomorph</a>