search
HomeWeb Front-endHTML TutorialCSS 常用命名 - 彼岸时光

  在前端开发中,规范使用 DIV+CSS 命名,可以增强团队合作提高开发效率,有利于页面后期的维护和优化。

1、页面结构

  wrap:外套、包裹,用于最外层。

  wrapper:外套,用于页面外围控制整体布局宽度。

  box:盒子,容器。

  header:头部,用于页头部分。

  nav:导航,主导航。

  main:主要区域,内容主体。

  content/container:内容,内容容器。

  sidebar:侧边栏。

  footer:底部,用于页脚部分。

2、功能区块

  left center right:左中右。

  main-left:左侧主要布局。

  main-right:右侧主要布局。

  logo:网站 LOGO 标志。

  search:搜索输入框。

  loginbar:登录条。

  regsiter:注册模块。

  banner:广告,用于横幅广告条。

  menu:菜单。

  submenu:子菜单,二级菜单。

  top:顶部。

  topnav:顶导航。

  mainnav:主导航。

  subnav:子导航,二级导航。

  leftsideBar:左导航。

  rightsideBar:右导航。

  topbar:顶部工具/菜单。

  bottom:底部。

  bottombar:底部工具栏。

  tool:工具条。

  shop:功能区,如购物车、收银台。

3、其他常用命名

  title:栏目标题。

  summary:摘要。

  hot:热门热点信息,推荐。

  msg:提示信息。

  news:新闻。

  list:列表,文章列表。

  piclist:图片列表。

  newslist:新闻列表。

  search-output:搜索输出。

  search-results:搜索结果。

  drop/dropdown:下拉。

  dropmenu/dorpdown-content:下拉菜单。

  scroll:滚动。

  homepage:首页。

  subpage:子页面,二级页面。

  tag:标签。

  tab:标签页。

  tips:小技巧。

  ranking:排行。

  vote:投票。

  bth:按钮。

  icon:图标。

  arr/arrow:箭头。

  status:状态。

  note:注释。

  skin:皮肤。

  current:当前的。

  active:活跃的,有效的。

  download:下载。

  friendLink:友情链接。

  copyright:版权信息。

  partner:合作伙伴。

  joinus:加入我们。

  sitemap:网站地图。

  siteinfo:网站信息。

  siteinfoLegar:法律声明。

  announcement:公告。

  guild:指南。

  service:服务。

  promotion:推广。

  blog:博客。

  forum:论坛。

4、产品相关命名

  keyword:关键词。

  products:产品。

  products-prices:产品价格。

  products-description:产品描述。

  products-review:产品评论。

  editor-review:编辑评论。

  news-products:最新产品。

  publisher:生产商。

  screenshot:缩略图。

  faqs:常见问题。

  barnding:商标。

  pay:充值。

  reputation:信誉。

5、常用的文件命名

  全局样式:global.css

  布局结构:layout.css

  基本共用:base.css

  综合样式:style.css

  主要的:master.css

  模块:module.css

  表单:forms.css

  主题/网页换肤:themes.css

  字体:font.css

  打印:print.css

  补丁:mend.css

  私有样式/独立页面,根据实际情况,可以自定义命名 CSS 文件。

  以上这些常用的文件命名,无需全部使用,根据实际情况,每个页面引用不超过 3 个 CSS 文件。

6、 ID 和 Class 命名规范

  (1)、主要的、重要的、特殊的、最外层的盒子使用 ID 属性命名,其他的都使用 class 属性命名。

  (2)、命名规则须以内容优先,表现为辅。首先根据所要呈现的内容、功能来命名,如果内容实在无法找到合适的命名,可以再根据表现命名。

  (3)、大多数情况下,命名都使用英文单词,可以增加代码的可读性,但特殊情况下,实在找不到合适的单词时,可以使用拼音命名,但必须简明,结构清晰。

  (4)、ID 和 Class 命名尽量全部都使用小写,多个单词可以使用连字符(-)链接,命名可以使用数字,但不能以数字开头。

  (5)、命名可以使用单词缩写,但必须确保是有效的缩写,即别人能看懂,不能自定义缩写。

 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment