Moh*_*lli 11 css asp.net asp.net-mvc
我正在使用ASP.NET MVC开发一个站点.CSS文件已增长到88KB,并且有5,000多行.我最近注意到最后添加的样式在浏览器中不存在.CSS文件或行数是否有任何大小限制?
编辑:对不起,我忘了提到在FireFox和IE8中Windows 7中都出现了这个问题.
Dan*_*son 12
我认为,如果您的css文件大小有问题,那么现在是时候重新考虑您的样式策略了.CSS中的C代表级联.很常见的情况是,当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.
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
链接是元素上有多个类的地方.例如:
<div class="box right small"></div>
Run Code Online (Sandbox Code Playgroud)
box
可能有一些一般的样式,你可能想要应用于许多块元素,如div,h1 ... h6,p,ul,li,table,blockquote,pre,form.small
是自我解释right
可能只是右边对齐,但右边填充4px.随你.关键是每个元素可以有多个类,并从可重用的构建块构建样式 - 单个样式设置的分组.否则称为类.
在一个非常简单的层面上,寻找组合样式的机会:
所以:
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;}
Run Code Online (Sandbox Code Playgroud)
变
h1, h2, h3 {font-family: tahoma, color: #333}
h1 {font-size:1.4em;}
h2 {font-size:1.2em;}
h3 {font-size:1.0em;}
Run Code Online (Sandbox Code Playgroud)
只是,稍微小一些,但很多次做这种事情,你可以有所作为.
另外,验证您的CSS.这将帮助您发现代码中的错误.
什么是CSS验证谈谈你的CSS规则?
剪切并粘贴样式表的最后"无效"规则:它们中的一些现在正在工作吗?
使用像PSPad,Notepad ++,Scite等好的文本编辑器可以看到明显的拼写错误" ; /* */
.它们的范围非常有限,;
或者很容易被看作是没有关闭的评论.我遇到的不太明显的是没有关闭括号:
background: green url(img/dummy_gradient.png left top no-repeat;
Run Code Online (Sandbox Code Playgroud)
直到下一个)
我的CSS规则下面的50行没有任何工作!
你的问题是:
CSS文件或行数是否有任何大小限制?
对于IE9及更低版本,答案是肯定的,这取决于你所说的"行"和"大小限制".
这篇关于MSDN的文章更多地讨论了最大选择器和链接样式表,以及它们在开发IE时如何得到这些数字.
没有限制.可能是文件被缓存,这是你没有看到修改的原因.尝试清除浏览器缓存或Ctrl+F5.
归档时间: |
|
查看次数: |
11342 次 |
最近记录: |