html – 具体类名称与类层次结构

html – 具体类名称与类层次结构,第1张

概述这些例子的最佳做法是什么? 1) <style type="text/css">.block .title {color:red}.anotherBlock .title {color:blue}</style>...<div class="block"> <h3 class="title">SomeTitle</h3></div><div class="anotherBlo 这些例子的最佳做法是什么?

1)

<style type="text/CSS">.block .Title {color:red}.anotherBlock .Title {color:blue}</style>...<div >    <h3 >SomeTitle</h3></div><div >   <h3 >anotherTitle</h3> </div> ...

2)

<style type="text/CSS">.blockTitle {color:red}.anotherBlockTitle {color:blue}</style>...<div >    <h3 >SomeTitle</h3></div><div >   <h3 >anotherTitle</h3> </div> ...

第一个代码看起来更干净,但它可以让某人认为h3标签将具有相同的样式属性.

解决方法
<style type="text/CSS">.block h3 {color:red}.anotherBlock h3 {color:blue}</style>...<div >    <h3>SomeTitle</h3></div><div >   <h3>anotherTitle</h3> </div>

为什么?因为它与您的示例一样可读,但写入的代码较少=在用户浏览器中渲染的时间较少

总结

以上是内存溢出为你收集整理的html – 具体类名称与类层次结构全部内容,希望文章能够帮你解决html – 具体类名称与类层次结构所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1069304.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存