推特 搜索 代码
You don't need a thousand lines of code to make a big difference in any coding language. Oftentimes it's quite the opposite: a few tiny code snippets can do a world of good and accomplish big things. I asked my Twitter followers to tweet to me their favorite tiny snippets of code -- that's a bit difference to try to pack into 140 characters! Here are my favorites from this round!
您不需要一千行代码就可以在任何一种编码语言中产生很大的不同。 通常情况恰恰相反:一些小巧的代码片段可以成就一个美好的世界,并成就大事。 我要求我的Twitter关注者向我发送他们最喜欢的小片段代码-尝试打包成140个字符有点不同! 这是我这一轮的最爱!
Want to make a HTML list of items look like a real, comma-separated list? Check this out:
想要使项目HTML列表看起来像真实的逗号分隔列表吗? 看一下这个:
@davidwalshblog Commas after list items, except the last. No server-side logic required! ul > li:not(:last-child)::after { content: ","; }
— Stephen Coogan (@coog_ie)@davidwalshblog列表项后的逗号(最后一个除外)。 无需服务器端逻辑! ul> li:not(:last-child):: after {content:“,”; }
— Stephen Coogan(@coog_ie) February 11, 2014 2014年2月11日I implemented this on my upcoming redesign with great effect, and used it on the MDN redesign.
我在即将进行的重新设计中实现了此效果,并产生了很大的效果,并在MDN重新设计中使用了它。
The following snippet use max-height to implement CSS-only sliders with overflow hidden:
以下代码段使用max-height来实现仅CSS滑块,其中隐藏了溢出:
@davidwalshblog .foo ul {max-height: 0;} .foo:hover{ ul { max-height: 1000px; transition: .3s ease; } } Animate to 'auto' height!
— Tobias (@quagliero)@davidwalshblog .foo ul {max-height:0;} .foo:hover {ul {max-height:1000px; 过渡:.3s缓解; 动画到“自动”高度!
— Tobias(@quagliero) February 11, 2014 2014年2月11日I wrote about this a while back -- and awesome technique that too few developers know about.
我前一阵子曾写过关于这一点的文章,这是一种极了的技术,很少有开发人员知道。
Want a nice 3-column grid generator for your SASS projects?
想要一个适合您的SASS项目的3列网格生成器吗?
@davidwalshblog *{box-sizing:border-box}.G{margin-left:-1em}[class*=C]{float:left;padding-left:1em}@each $i in 1,2,3{.C#{$i}{width:33%*$i}}
— Jonathan Bennett (@jonbca7)@davidwalshblog * {box-sizing:border-box} .G {margin-left:-1em} [class * = C] {float:left; padding-left:1em} @每个 1,2,3中的$ i { .C#{$ i} {width:33%* $ i}}
—乔纳森·贝内特(@ jonbca7) February 12, 2014 2014年2月12日I'm impressed this could fit in a tweet but well done!
我印象深刻,这可能适合一条推文,但做得很好!
Ever wanted to swap the contents of two JavaScript vars? Probably not but hey, it's pretty simple:
是否曾经想交换两个JavaScript变量的内容? 可能不是,但是,这很简单:
@davidwalshblog Swap variables in JS: b = [a, a = b][0]
— aksival (@aksival)@davidwalshblog交换JS中的变量:b = [a,a = b] [0]
— aksival(@aksival) February 13, 2014 2014年2月13日Not the most practical but I expected there to be more code involved.
不是最实用的,但是我希望其中涉及更多代码。
Hovering over an abbr element usually gives you the full text representation, but what if you're on mobile? Here's the answer:
将鼠标悬停在abbr元素上通常可以为您提供全文表示,但是如果您在移动设备上怎么办? 答案是:
@davidwalshblog abbr[title]:after { content: " (" attr(title) ")"; } /* for use on mobiles, in a media query or something */
— Callum Macrae (@callumacrae)@davidwalshblog abbr [title]:之后{content:“(” attr(title)“)”; } / *用于在手机,媒体查询或其他方面* /
— Callum Macrae(@callumacrae) February 12, 2014 2014年2月12日You could do this with a number of properties, but this is a nice usage.
您可以使用许多属性来执行此操作,但这是一个很好的用法。
I had no idea what I'd see when I executed this into the JavaScript console, but I'll let it act as the conclusion to this post:
我不知道在JavaScript控制台中执行此操作时会看到什么,但我将其作为本文的结论:
@davidwalshblog ([]+{})[+!+[]+!+[]]+(+(+!+[]+([]+[][+[]])[+!+[]+!+[]+!+[]]+(+!+[])+(+[])+(+[])+(+[]))+[])[7]+([]+[][+[]])[+!+[]+!+[]+!+[]]
— Minko Gechev (@mgechev)@davidwalshblog ([] + {})[+!+ [] +!+ []] +(+(+!+ [] +([] + [] [+ []])[+!+ [] + !+ [] +!+ []] +(+!+ [])+(+ [])+(+ [])+(+ []))+ [])[7] +([] + [ ] [+ []])[+!+ [] +!+ [] +!+ []]
— Minko Gechev(@mgechev) February 13, 2014 2014年2月13日See you next time! I can't wait to see what you all come up with next!
下次见! 我等不及要看你们接下来要提出什么!
翻译自: https://davidwalsh.name/tweet-code-2
推特 搜索 代码
相关资源:twitter分享