计算机科学中最困难的问题:居中对齐

Translations: Russian

翻译:俄语

This is my claim: we, as a civilization, forgot how to center things.

这是我的观点:作为一个文明,我们忘记了如何居中事物。

I mean, we know how to do it. It has never been simpler:

我的意思是,我们知道如何做到。这从未如此简单:

display: flex;
justify-content: center; /* Horizontal centering */
align-items: center; /* Vertical centering */

(don’t ask why you need to remember four words instead of just horizontal/vertical, it’s still better than before)

(不要问为什么你需要记住四个单词而不是只有水平/垂直,这仍然比以前好

Or you can use grids if you want:

或者你也可以使用网格:

display: grid;
justify-items: center; /* Horizontal centering */
align-items: center; /* Vertical centering */

(also don’t ask why justify-content became justify-items)

(也不要问为什么justify-content变成了justify-items

If you feel like school today, we can deduce it from the first principles:

如果你今天感觉像上学,我们可以从第一原理推导出来:

Hey, even ChatGPT knows how to center things:

嘿,连 ChatGPT 都知道如何居中:

Okay, maybe not right away, but eventually it gets there.

好吧,也许不是立刻,但最终会实现。

What I’m saying is: everybody knows how to center things. It’s trivial. And if you are lost, the knowledge is right there.

我要说的是:每个人都知道如何居中。这是微不足道的。如果你迷失了方向,知识就在那里。

Yet, when we look at actual applications, we see that these methods are not used. We see this:

然而,当我们看实际应用时,我们发现这些方法并没有被使用。我们看到这样的情况:

or this:

或者是这样:

or even this:

甚至是这样:

So something is clearly getting lost between know-how and applying that knowledge.

所以显然在知识和应用知识之间有些东西被忽略了。

In theory, there’s no difference between theory and practice. Unfortunately, we live in practice.

理论上,理论和实践之间没有区别。不幸的是,我们生活在实践中。

So what’s happening? Let’s find out.

那么,发生了什么?让我们找出来。

Fonts

字体

Fonts are one of the biggest offenders. You can see poorly aligned text everywhere. Let me showcase.

字体是最大的问题之一。你可以在各个地方看到排版不良的文本。让我来展示一下。

Apple can’t do it:

苹果公司无法做到:

Microsoft can’t do it:

微软无法做到:

GitHub can’t do it:

GitHub无法做到:

Valve can’t do it:

Valve无法做到:

Slack can’t do it:

Slack无法做到:

Telegram can’t do it:

Telegram 无法做到:

Google Maps can’t do it:

Google 地图无法做到:

Honestly, I can provide an endless supply of poorly-aligned buttons without even h...

开通本站会员,查看完整译文。

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-06 05:16
浙ICP备14020137号-1 $bản đồ khách truy cập$