简体   繁体   English

CSS文件不断变化

[英]CSS file keeps changing

I have the following CSS in my main.css file: 我的main.css文件中有以下CSS:

background-image:-moz-linear-gradient(top, #eeeeee, #aaaaaa) !important;
background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#eeeeee), to(#aaaaaa)) !important;
background-image:-webkit-linear-gradient(top, #eeeeee, #aaaaaa) !important;
background-image:-o-linear-gradient(top, #eeeeee, #aaaaaa) !important;
background-image:linear-gradient(to bottom, #eeeeee, #aaaaaa) !important;
background-repeat:repeat-x;
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffeeeeee', endColorstr='#ffaaaaaa', GradientType=0) !important;

Which keeps changing itself to: 不断改变自己:

background-image: linear-gradient(to bottom, #eeeeee, #aaaaaa) !important;

Why could this be happening? 为什么会发生这种情况? The selector is .navbar .nav which is defined in another CSS file too, the Bootstrap CSS file. 选择器是.navbar .nav ,它也在另一个CSS文件中定义,即Bootstrap CSS文件。 Could it be that Visual Studio is automatically cleaning up duplicate definitions or something? 是Visual Studio会自动清理重复的定义还是什么?

edit: It changes every few builds. 编辑:它改变了每一个版本。 I can't pinpoint what action is causing it to automatically change. 我无法确定导致其自动更改的操作。

Those are browser based CSS tags: 这些是基于浏览器的CSS标签:

This only works in mozilla: 这仅适用于mozilla:

background-image:-moz-linear-gradient(top, #eeeeee, #aaaaaa) !important;

Works in Chrome/Webkit based browsers: 适用于基于Chrome / Webkit的浏览器:

background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#eeeeee), to(#aaaaaa)) !important;
background-image:-webkit-linear-gradient(top, #eeeeee, #aaaaaa) !important;

Actually this cross browser technique is somewhat deprecated in the release of CSS3. 实际上,这种跨浏览器技术在CSS3的发布中有所弃用。 You need to find the corresponding CSS that works on the browser you are using. 您需要找到适用于您正在使用的浏览器的相应CSS。

It's not 'changing' just that, other CSS was ignored by the browser. 它并没有“改变”,浏览器忽略了其他CSS。

Have a look to see if there are any build events setup in Visual Studio. 看看Visual Studio中是否有任何构建事件设置。 It's possible the project has been configured to run something like csstidy or a css minimizer that is attempting to cleanup duplicate properties. 项目可能已经配置为运行csstidy或css minimizer之类的东西,试图清理重复的属性。

Alternatively, if you're using source control (which I would hope you are), your source control may be configured to run a commit hook that does the same sort of thing. 或者,如果你正在使用源代码控制(我希望你是这样),你的源代码控制可能被配置为运行一个提交钩子来做同样的事情。 How that is configured will depend on the source control that you're using. 如何配置将取决于您正在使用的源控件。

I wouldn't expect this to be a problem with a modern version of csstidy (or any other modern css optimising tool for that matter). 我不希望这是一个现代版本的csstidy(或任何其他现代css优化工具)的问题。 However, if this is a project that you've inherited, it's possible it was setup some time ago with a tool that is now out of date. 但是,如果这是您继承的项目,那么很可能它是在不久前使用现在已过时的工具设置的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM