CSS助记符:你如何记住#或.是用于班级还是ID?

发布于 2024-10-18 10:20:08 字数 155 浏览 2 评论 0原文

#testid="test" 的选择器

.testclass="test" 的选择器

但是如何记住它们的方向(例如不是.=id)

#test is the selector for id="test"

.test is the selector for class="test"

but how do you remember which way round they are (eg not .=id)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

二手情话 2024-10-25 10:20:08

好吧,事实上,这些事情是如此常见,以至于大多数人不需要助记符来记住它们,但我想出了一些东西,如果它有帮助的话:

就文件名而言,a . ,然后是扩展名表示事物的类型。这种类型可以有很多不同的东西。通过 CSS,使用类,您可以为相同类型的许多元素表示单一样式。

就 URL 而言,# 表示指向文档中特定位置的锚链接。它仅指一个位置。通过 CSS,您可以使用 ID 来表示单个特定元素的单个样式。

Well, in truth these things are so common that most people don't need mnemonics to remember them, but here's something I came up with, if it helps:

In terms of a filename a . and then an extension denotes a type of thing. There can be many different things of this type. With CSS, using classes you can denote a single style for many elements of the same type.

In terms of a URL, a # denotes an anchor link to a specific spot in the document. It refers to one location only. With CSS, using IDs you denote a single style for a single specific element.

醉南桥 2024-10-25 10:20:08

如果警察发现您有“哈希”行为,他会要求查看您的身份证件。如果不是,你就可以保持优雅。这确实很愚蠢,但我就是这样记住的。

If a police officer catches you with "hash," he will ask to see your ID. If not you get to stay classy. It's really dumb, but that's how I remember.

删除会话 2024-10-25 10:20:08
  • 来电者ID显示电话#
  • 周期像珍珠一样圆,而且——珍珠优雅

(PS:那些“你学得和我不一样,所以你很糟糕”的评论是怎么回事?天啊。重复对我来说没问题,但如果我能想象一些东西,我就能更快地掌握东西。事实上,越奇怪的东西越容易记住!

  • CallerID shows a phone #.
  • Periods are round like pearls, and-- Pearls are classy.

(P.S.: What's with all the "you learn differently than me, so you suck" comments? Goodness. Repetition is OK for me, but if I can visualize something I pick things up more quickly. In fact, the weirder something is the easier it is to memorize!)

溺深海 2024-10-25 10:20:08

我学习它的方式与我学习引号(而不是括号)用于属性值的方式相同 - 通过输入几次。

但是,如果您或您认识的人被 #. 绊倒,请考虑许多编程语言使用 . 来访问类类型的对象。

I learned it the same way I learned that quotes (rather than parentheses) are used for attributes' values — by typing them a couple of times.

If you or someone you know gets tripped up by # vs ., though, consider that many programming languages use a . to access the members of an class-typed object.

樱&纷飞 2024-10-25 10:20:08

我发现我迟到了一天(可能还差一美元),但我在早期也遇到了同样的问题,以下内容有所帮助:
对于作为 Class 选择器的点 (.),我记得它是:“我的课程总是从点开始,不会早一分钟或晚一分钟。”
对于ID的数字符号(#),我只是提醒自己,没有号码的身份证(entification)卡是不完整的。

I see I'm a day late (and maybe a dollar short), but I had the same problem in the early days and the following helped:
for the dot (.) as the selector for Class, I remembered it as: "My class always starts on the dot, not a minute early or late."
for the number sign (#) for ID, I just reminded myself that an ID(entification) card is incomplete without its number.

笔芯 2024-10-25 10:20:08

花大量时间编写 CSS。当你犯错的次数足够多时,你的大脑就会屈服并保留它。

Spend lots of time writing CSS. When you've got it wrong enough times, your brain will give in and retain it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文