拖了很久,今天终于要发布了,功能和使用方法看CssGaga帮助吧(内有视频演示)
解压了就能用,前提是装了.NET Framework 2.0+
这个跟之前项目里使用的有些差别:
- 重新调整了思路,代码改动较大,未在实践中检验,所以大家注意BUG并反馈哈
- 精简了界面,将一些功能(去注释、格式化、不换行压缩)默认开启,不再提供复选框进行设置
从神飞那里借了本《高性能网站建设进阶指南》,粗略读了一遍,最重要的收获是第10章图像优化纠正了我对256色的认识
Truecolor versus palette image formats
Using the RGB color model, how many distinct colors can you represent in a graphic? The answer is more than 16 million: 255 * 255 * 255 (or 224) gives you 16,777,216 combinations. Image formats that can represent this many colors are called truecolor image formats; examples are JPEG and the truecolor type of PNG.
To save space when storing the image information in a file, one technique is to create a list of all the unique colors found in the image. The list of colors is called a palette (also called an index). Having the list of colors, you can represent the image by keeping track of which palette entry corresponds to each pixel.
The palette can contain any RGB value, but the most common palette image formats GIF and PNG8—limit the number of palette entries to 256. This doesn’t mean you can pick from only 256 predefined colors. On the contrary, any of the 16+ million colors
are up for grabs, but you can only have up to 256 of them in a single image.
最后一段说GIF和PNG8最多只能包含256色,并不意味着只能从256种已定义好的颜色中选择,可以从224种颜色中挑选!
另外,本章还给出一些关于CSS Sprite的优化建议
Highly Optimized CSS Sprites
Sometimes optimizing sprites is more complex than optimizing images. Diverse resources combined in one sprite may be harder to compress well. Following these best practices will make your sprite as small as possible:
- Combine like colors; for example, sprite icons with a similar color palette.
- Avoid unnecessary whitespace, making images easier to process on mobile devices.
- Arrange elements horizontally instead of vertically. The sprite will be slightly smaller.
- Limit colors to stay within the 256-color limit of PNG8.
- Optimize individual images, and then the sprite. Color reduction will be easier with a limited palette.
- Reduce anti-aliased pixels via size and alignment. If an icon is slightly off-square, you can often reduce the anti-aliased pixels by aligning the image horizontally or vertically.
- Avoid diagonal gradients, which cannot be tiled.
- Avoid alpha transparency in Internet Explorer 6 or quarantine images that require true alpha transparency in a separate sprite.
- Change the gradient color every two to three pixels, rather than every pixel.
- Be careful with logos. They are very recognizable, so even small changes are likely to be noticed.
<appSettings> <!-- 是否默认选中去换行 --> <add key="chkCompress" value="0"/> <!-- 是否默认选中合并import文件 --> <add key="chkImport" value="1"/> <!-- 是否默认选中生成本地文件 --> <add key="chkLocal" value="0"/> <!-- 本地路径 请注意格式对应 下同 --> <add key="pathSource" value="E:\isd_webrebuild_rep\qzonev5_proj\trunk\qzonestyle\" /> <!-- 对应的CSS站点路径,以下功能会用到:1.MHTML for IE6&7; 2.MHTML AlphaImageLoader for IE6; 3.自定义cursor --> <add key="webSiteUrl" value="http://imgcache.qq.com/qzonestyle/"/> <!-- 目的路径1 比如72 需有写权限软件才能正常运行 请提前登陆 --> <add key="pathDest1" value="\\172.25.32.72\imgcache\qzonestyle\"/> <!-- 目的路径名 不要搞太长 --> <add key="pathDest1Name" value="拷到72"/> <!-- 目的路径1是否选中 --> <add key="chkDest1" value="0"/> <!-- 目的1自动登录脚本,没有请保持value为空 --> <add key="cmdDest1" value=""/> <add key="pathDest2" value="\\172.25.32.139\imgcache\qzonestyle\"/> <add key="pathDest2Name" value="拷到139"/> <add key="chkDest2" value="0"/> <!-- 目的2自动登录脚本,没有请保持value为空 --> <add key="cmdDest2" value="139.bat"/> <!-- 慎用!!!本地路径过滤需过滤的字符串,没有请保持value为空 --> <add key="pathReplace" value=".yt"/> <!-- 是否选中备份 --> <add key="chkBackup" value="1"/> </appSettings>
style.source.css → style.css
@import url("reset.import.source.css");
html >/**/ body
此种hack方式中的注释会被过滤掉而导致hack失效,请选用其他的hack方式
.base64{background-image:url('base64/logo.png');}
注意不要使用缩写,否则工具取不到值(因为要自动生成支持IE6/7的mthml)
生成后的代码为
/*
Content-Type:multipart/related;boundary="_YTZONG"
--_YTZONG
Content-Location:logo.png
Content-Transfer-Encoding:base64
[base64 string]
--_YTZONG--
*/
.base64{background-image:url(data:image/png;base64,[base64 string]);#background-image:url(mhtml:http://imgcache.qq.com/qzonestyle/css/style.css!logo.png);}
如果为含有alpha透明的png图片,命名以“.alpha.png”结尾可自动生成IE6的AlphaImageLoader滤镜,即
.base64{background-image:url('base64/shadow.alpha.png');}
生成后的代码为
/*
Content-Type:multipart/related;boundary="_YTZONG"
--_YTZONG
Content-Location:shadow-24.png
Content-Transfer-Encoding:base64
[base64 string]
--_YTZONG--
*/
.base64{background-image:url(data:image/png;base64,[base64 string]);#background-image:url(mhtml:http://imgcache.qq.com/qzonestyle/css/style.css!shadow.alpha.png);_background-image:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='mhtml:http://imgcache.qq.com/qzonestyle/css/style.css!shadow.alpha.png',sizingMethod='scale');}
为保证跨浏览器兼容,若图片转换为base64 string后的长度超过IE8限制则不予转换!详见 http://www.99css.com/?p=492
@import url("reset.import.source.css");
@import url("grid.import.source.css");
@import url("mod-1.source.css");
@import url("mod-2.css");
生成后
@import url("mod-2.css");
[reset.import.source.css 处理后的代码]
[grid.import.source.css 处理后的代码]
[mod-1.source.css 处理后的代码]
另外若mod-1.source.css中import了其他css文件则不进行处理
@echo off net use \\172.25.32.139 密码 /USER:用户名
选中72或139时会自动调用相应的登录批文件文件进行自动登录
选中备份会在覆盖文件之前进行备份,备份文件在目标路径下建立backup文件夹并生成css文件名+日期.css(或图片)的文件
<img src="data:image/png;base64,[base64 string]">
选中拷到72或拷到139会拷贝至72及139
-moz-border-radius:3px;
生成
-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;
大家都是用firefox开发吧,开发阶段直接写“-moz-”的就好
你有想法也可直接与我联系,工具随后发布,文档先行:)
很久之前写了使用 background:url(#) 解决 IE bug,原理是请求一张不存在的图片,不过写法有些问题。
写为
background:url(#)
会增加一个http请求,比如当前css的URL为
http://imgcache.qq.com/qzonestyle/project/css/xxx.css
则会多请求一次
http://imgcache.qq.com/qzonestyle/project/css/xxx.css#
和以下类似(详见解决IE6.0.2800压缩HTTP数据Bug之草记)
http://imgcache.qq.com/qzonestyle/project/css/xxx.css?t=20100710.css
这样写可以避免这个问题
background: url(iesucks);
——————- 亡羊补牢的分隔线 2010-7-17 ——————-
上面的测试过程有些问题,经过用真实环境重新测试这样搞效果更差,若调用该css的页面地址是
http://www.99css.com/
则会先请求
http://www.99css.com/iesucks
之后301转向至
http://www.99css.com/iesucks/
改用透明图片不太甘心,不如变态一点,直接调用该css本身,因为css已经被下载并缓存了
background: url(http://imgcache.qq.com/qzonestyle/project/css/xxx.css);
深圳华为(有可能是其子公司)
待遇不错,急招!(上次招前端没好人选,后面找了外包公司,汗~)
简历至:hungjunling@huawei.com
根据电话记录整理(让他发邮件给我具体要求,说是公司有么斯限制),有疑问邮件联系
前些天不知哪个feed反刍,看到老赵几年前发的这篇《意外得到了一个免费的HttpWatch Professional的License》,是不是在预示着什么?
今天向往常一样Google Reader,看到httpwatch 7.0搞发布活动HttpWatch 7.0: Spot the Differences!,于是就简单掺和了一下,没想到抢了沙发,license也到手了。
给httpwatch做个广告,原因嘛你懂的
7.0增加了4个新功能
2010-6-7正式发布,期待~