CSS 和文件名编码约定
您(或您的公司)对文件名和 CSS 类名采用哪种约定?例如,假设您有以下类名称:窗口、窗口顶部、窗口左上、窗口右上。如何命名这些类名(以及此类文件名)?
目前我正在做以下事情:
.window {
background: url(images/window.png);
}
.window-top {
background: url(images/window-top.png);
}
.window-top-left {
background: url(images/window-top-left.png);
}
还有什么其他方法?
What kind of convention do you (or your company) run on filenames and CSS class names? For example, let's say you have these class names: window, window top, window top left, window top right. How do you name those class names (and such filenames)?
Currently I am doing the following:
.window {
background: url(images/window.png);
}
.window-top {
background: url(images/window-top.png);
}
.window-top-left {
background: url(images/window-top-left.png);
}
What other ways are there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从类名来看,我认为这是某种小部件或插件的 CSS。您给出的名称非常清晰,但为了避免冲突,我可能会在它们前面加上一个简短的插件/小部件特定字符串,即:
这些名称有点冗长,但从长远来看应该有助于使事情变得更清晰。
如果我错了,那么你暗示的命名约定应该没问题 - 最重要的是你是一致的。
From the class names, I assume this is CSS for some sort of widget or plugin. The names you have given are pretty clear but to help avoid clashes I'd probably prefix them with a short plugin/widget specific string ie:
These names are a little verbose, but should help make things clearer in the long run.
If I'm mistaken, then the naming convention you are hinting at should be fine - whats most important is that you are consistent.