博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
css–sprit_高级CSS –类已用完–通过使用结构化格式标签避免类
阅读量:2515 次
发布时间:2019-05-11

本文共 2498 字,大约阅读时间需要 8 分钟。

css–sprit

Nothing makes me cringe more than when I see other programmers use a class declaration for every XHTML tag in their programming. Using too many CSS class declarations can result in:

当我看到其他程序员在其编程中的每个XHTML标记中使用类声明时,没有什么比让我更畏缩的了。 使用过多CSS类声明可能会导致:

  • Bloated page downloads for the user

    用户的膨胀页面下载
  • Bloated CSS file downloads for the user

    用户的膨胀CSS文件下载
  • Difficulty in editing CSS files due to so many classes for the programmer

    由于程序员需要太多的类,因此难以编辑CSS文件
  • Using meaningless class names to try to save space

    使用无意义的类名尝试节省空间

There's a more efficient way to code your pages without using a lot of classes: use formatting tags. A CSS purist would say that all formatting should take place in the CSS file, so we'll have that covered. Also, we'll put to use some tags that we probably wouldn't use otherwise.

有一种无需使用很多类即可对页面进行编码的更有效方法:使用格式标记。 一个CSS纯粹主义者会说所有格式都应该在CSS文件中进行,因此我们将对此进行介绍。 另外,我们将使用一些我们可能不会使用的标签。

代码 (The Code)

Here's the CSS code I'll use:

这是我将使用CSS代码:

strong, font, em, big, small, i { display:block; font-weight:normal; font-style:normal; margin:0; padding:5px; font-size:11px; }strong	{ width:700px; margin:10px auto; }font	 { height:100px; background:pink; }em	 { width:150px; height:300px; float:left; background:lightblue; }big	  { width:400px; height:300px; float:left; background:lightgreen; }small	 { width:120px; height:300px; float:left; background:lightyellow; }i	   { background:#fffea1; height:100px; clear:both; }

Here's the XHTML structure I'll use withing the page:

这是我将在页面中使用的XHTML结构:

			{ This is the header }				{ This is the navigation bar }				{ This is the content pane }				{ This is the sidebar }				{ This is the footer }	

问题 (The Issues)

While the above works, many would argue that the above is bad practice because:

尽管上述方法有效,但许多人认为上述做法是错误的做法,因为:

  • It may bring page validation issues

    它可能会带来页面验证问题
  • Code may be more difficult to maintain because the programmer wouldn't remember how he/she is using each tag

    代码可能更难以维护,因为程序员将不记得他/她如何使用每个标签
  • Some programmers may prefer using formatting tags for formatting.

    一些程序员可能更喜欢使用格式化标签进行格式化。

I would have no issue using the code above. The worst issue I can identify from the list is that the page may not validate, but page validation often isn't necessary as long as the page functions as it should.

使用上面的代码,我不会有任何问题。 我可以从列表中识别出的最糟糕的问题是页面可能无法验证,但是只要页面能够正常运行,通常就不需要页面验证。

What are your thoughts? Have you ever used this type of formatting? Do you take issue with the above code?

你觉得呢?你有没有什么想法? 您曾经使用过这种格式吗? 您是否对上述代码有疑问?

翻译自:

css–sprit

转载地址:http://qvvwd.baihongyu.com/

你可能感兴趣的文章
Why Normal--牛人都干啥去了?
查看>>
[转载]MySQL concat函数的使用
查看>>
go: writing stat cache:, permission denied
查看>>
Xcode7.0.1(ios9)的部分适配问题
查看>>
hdu---(2604)Queuing(矩阵快速幂)
查看>>
关于Easyui的窗口和tab页面不执行JS的原因说明
查看>>
机器学习入坑指南(七):机器学习的知识结构
查看>>
又是企鹅惹的祸
查看>>
基于jQuery点击圆形边框弹出图片信息
查看>>
基于jQuery扁平多颜色选项卡切换代码
查看>>
swift 日历的制作
查看>>
【转】C++常见错误大全
查看>>
使用Jackson来实现Java对象与JSON的相互转换的教程
查看>>
nginx通过keepalived实现高可用的负载均衡
查看>>
Java读取txt文件和覆盖写入txt文件和追加写入txt
查看>>
python学习,day4:生成器
查看>>
leetcode 206. Reverse Linked List
查看>>
数据库学习
查看>>
【转】数据结构和算法 — 二叉树
查看>>
ajaxStart 和 ajaxSend 不执行
查看>>