CSS CSS边距和填充速记属性顺序的助记符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/356759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:09:44  来源:igfitidea点击:

A mnemonic for the order of CSS margin and padding shorthand properties

cssmnemonics

提问by dland

I can never remember the order of the shorthand property for setting the margin or padding in one declaration. That is:

我永远不记得在一个声明中设置边距或填充的速记属性的顺序。那是:

margin-top:    2px;
margin-bottom: 4px;
margin-left:   3px;
margin-right:  8px;

may be written as

可以写成

margin: 2px 8px 4px 3px;

Yes I understand that one can visualise the order by thinking of a clock, starting at midday and moving clockwise. But I keep forgetting about that. I need to recall the order top, right, bottom, left textually.

是的,我知道人们可以通过思考时钟来形象化顺序,从中午开始并顺时针移动。但我总是忘记这一点。我需要在文本上回忆起顶部、右侧、底部、左侧的顺序。

Hence, T B L RT R B L.

因此,TBLRTRB L。

Something like This [R-noun] [B-verb] [L-nouns] is perhaps the way to go but I feel myself lacking inspiration. If anyone has come across a useful mnemonic for this I'd love to hear it. Like a good meme, I'm sure once I get something lodged in my brain I will be unlikely to forget it.

像 This [R-名词] [B-动词] [L-名词] 之类的东西也许是要走的路,但我觉得自己缺乏灵感。如果有人为此遇到过有用的助记符,我很想听听。就像一个好的模因,我敢肯定,一旦我的大脑中存有一些东西,我就不太可能忘记它。

NOTE: This question gave incorrect information - the order (as noted in some of the comments and answers) is Top Right Bottom Left. (heh, see what I mean? -- dland)

注意:这个问题提供了不正确的信息 - 顺序(如某些评论和答案中所述)是Top Right Bottom Left。(呵呵,明白我的意思吗?--dland)

回答by Paul Dixon

If you don't get it right, there will be TRouBLe

如果你没有做对,就会有麻烦

回答by Yuval Adam

Actually the clock thing works perfectly. It is the most intuitive way to remember it, at least for me.

实际上时钟的东西工作得很好。这是最直观的记忆方式,至少对我来说是这样。

回答by Paul Dixon

Tricky Rectangle Border Logic ?

棘手的矩形边框逻辑?

回答by Steve

Why don't just remember that the order goes clockwise starting from the TOP:

为什么不记住顺序从顶部开始顺时针进行:

TOP -> RIGHT -> BOTTOM -> LEFT

顶部 -> 右侧 -> 底部 -> 左侧

回答by Paul Dixon

Another attempt:

另一种尝试:

Tyrannosaurus Rex : Big Lizard

霸王龙:大蜥蜴

回答by Paul Dixon

The Really Big Lebowski

真正的大莱博夫斯基

回答by Logan Serman

Just think clockwise, it's the easiest way. Starts at the top and goes around... much easier to remember than some silly phrase (provided you know how to read a clock...)

想想顺时针,这是最简单的方法。从顶部开始,然后循环……比一些愚蠢的短语更容易记住(前提是您知道如何阅读时钟……)

回答by Adam Rezich

TRo u BLe.

T Rou B Le。

回答by Paul Dixon

Timewise Rotation, Bit Lame?

时间轮换,有点蹩脚?

回答by Paul Dixon

Try Roast Beef Leftovers ?

试试烤牛肉剩饭?