css文件大小有什么限制吗? [英] is there any limit on css file size?

查看:285
本文介绍了css文件大小有什么限制吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET MVC开发网站。 CSS文件已经增长到88KB,有一个更多的5000行。我最近注意到,最后添加的样式在浏览器中不存在。 CSS文件或行数有任何大小限制吗?

I am using ASP.NET MVC to develop a site. The CSS file has grown to 88KB and is having a little more 5,000 lines. I noticed recently that styles added at the end are not there in the browser. Is there any size limit on CSS file or on the number of lines?

编辑
对不起,我忘了提及问题出现在Windows 7中的FireFox和IE8。

EDIT: Sorry I forgot to mention that this problem is occurring in Windows 7 both in FireFox and IE8.

推荐答案

我认为如果你有问题, css文件,则是时候重新思考您的样式策略。 CSS中的C代表级联。很多时候CSS文件太大了,是因为样式在适当的时候并没有通过使用级联行为来重用。

I think that if you are having problems with the size of your css files then it is time to rethink your styling strategy. The C in CSS stands for cascading. Quite often when CSS files get too big it is due to styles not being re-used where appropriate and through poor use of the cascading behaviour.

我不说这个轻轻。我曾在一些大型,复杂的零售网站工作,目前在非常复杂的金融交易应用程序。每当我来到超过几百种样式的网站时,我们通过降低CSS复杂性,在设计,减少复杂性和提高可维护性方面取得了巨大的改进。

I don't say this lightly. I have worked on some large, complex retail sites and currently on very complicated financial trading applications. Whenever I have come accross sites with more than a few hundred styles, we have achieved large improvements in design, reductions in complexity and improvement of maintainability by reducing css complexity.

一个开始的地方是在 css重置上执行Google搜索。有多个不同的实现,但是他们通常遵循的主题是覆盖每个浏览器的布局的差异,并删除任意边框,边距和填充等。从一个干净的slate开始,如果你愿意。然后,您可以从那里开始构建您的样式,谨慎使用级联 css链接

One place to start is doing a Google sesarch on css reset. There are multiple different implementations, but they generally follow the theme of overriding the differences in layout for each of the browsers and removing arbitrary borders, margins and padding etc. Starting with a clean slate, if you will. Then you can go ahead and build up your styles from there, being careful to make the most of cascading and css chaining

链接是元素上有多个类的地方。例如:

Chaining is where you have more than one class on an element. eg:

<div class="box right small"></div>  



可能喜欢应用于许多块元素,如div,h1 ... h6,p,ul,li,table,blockquote,pre,form。 small 是自说明 right 可能只是右对齐,但右边填充4px。随你。关键是你可以对每个元素有多个类,并从可重用的构建块中创建样式 - 单独样式设置的分组。

box might have some general styles that you might like to apply to many block elements such as div, h1...h6, p, ul, li, table, blockquote, pre, form. small is self explanatory right might simply be aligned to the right, but with a right padding of 4px. Whatever. The point is that you can have multiple classes per element and build up the styling from reusable building blocks - groupings of individual style settings. Otherwise known as classes.

在一个非常简单的级别上,查找oportunities以组合样式:

On a very simple level, look for oportunities to combine styles:

h1 {font-family: tahoma, color:#333333; font-size:1.4em;}  
h2 {font-family: tahoma, color:#333333; font-size:1.2em;}  
h3 {font-family: tahoma, color:#333333; font-size:1.0em;}  

成为

h1, h2, h3 {font-family: tahoma, color: #333}  
h1 {font-size:1.4em;}  
h2 {font-size:1.2em;}  
h3 {font-size:1.0em;}  

此外, 验证您的CSS 。这将有助于您发现代码中的错误。

Also, Validate your css. This will help you spot errors in your code.

这篇关于css文件大小有什么限制吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆