我一直非常依赖CSS来开发一个正在工作的网站。现在,所有CSS样式都在每个标记的基础上应用,因此现在我尝试将其移至更多外部样式中,以帮助将来进行任何更改。
但是现在的问题是,我注意到我遇到了“ CSS爆炸”。对我来说,决定如何最好地组织和抽象CSS文件中的数据变得越来越困难。
我div
从大量基于表格的网站使用网站中的大量标签。因此,我得到了许多如下所示的CSS选择器:
div.title {
background-color: blue;
color: white;
text-align: center;
}
div.footer {
/* Styles Here */
}
div.body {
/* Styles Here */
}
/* And many more */
It's not too bad yet, but as I am a beginner, I was wondering if recommendations could be made on how best to organize the various parts of a CSS file. I don't want to have a separate CSS attribute for every element on my website, and I always want the CSS file to be fairly intuitive and easy to read.
My ultimate goal is to make it easy to use the CSS files and demonstrate their power to increase the speed of web development. This way, other individuals that may work on this site in the future will also get into the practice of using good coding practices, rather than having to pick it up the way I did.
这里有一些很棒的材料,有些花了一些时间来回答这个问题,但是当涉及到单独的样式表或单独的样式表时,我将使用单独的文件进行开发,然后将所有用于站点的通用css合并到一起部署时将其合并为一个文件。
这样一来,您便可以兼得两全,提高了性能(减少了从浏览器请求的HTTP请求),并且在开发时分离了代码。