31
七 10

CssGaga 2010 Beta1

拖了很久,今天终于要发布了,功能和使用方法看CssGaga帮助吧(内有视频演示)

下载CssGaga

解压了就能用,前提是装了.NET Framework 2.0+

这个跟之前项目里使用的有些差别:

  1. 重新调整了思路,代码改动较大,未在实践中检验,所以大家注意BUG并反馈哈
  2. 精简了界面,将一些功能(去注释、格式化、不换行压缩)默认开启,不再提供复选框进行设置

17
七 10

256色

神飞那里借了本《高性能网站建设进阶指南》,粗略读了一遍,最重要的收获是第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.

14
七 10

CssGaga帮助

视频演示

下载

基本配置

<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>

使用说明

  1. css文件名以“.source.css”结尾,供开发使用(SVN只需托管.source.css),经工具生成后会去除“.source”用于发布,即
    style.source.css → style.css
  2. 为防止生成冗余文件,以“.import.source.css”结尾的文件拖进来不会复制到目的路径,故import进来的文件推荐以“.import.source.css”结尾
    @import url("reset.import.source.css");
  3. 工具会对css进行去注释、格式化、压缩等处理,注意
    html >/**/ body

    此种hack方式中的注释会被过滤掉而导致hack失效,请选用其他的hack方式

  4. 将要生成data URI的图片放在base64文件夹中(这样做的目的是你可以有选择的对图片进行data URI),base64文件夹与css文件同级

    开发时代码格式为:

    .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

  5. 转换自定义鼠标指针路径为绝对路径(由于IE里有bug),格式与base64类似,不过这个是要放在css同级的cursor文件夹中
  6. 合并import文件,开发过程中会通过import方式引入css文件(类似Efficient, maintainable CSS(偶们组美女jeanne的中文翻译)中的bridging css,强烈建议bridging css只做import使用,不要在其中写其他的css代码,否则可能引起开发同发布文件选择器的优先级变化),工具可并入import的css文件,不过前提是只能import同级的文件,并且以“.source”结尾,否则不会合并,例如:
    @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文件则不进行处理

  7. 去换行功能为将除MHTML外的css整理为一行
  8. 拷到72、拷到139为拷到两个目的环境,可自行配置路径及名称(比如可配置为测试环境、预发布环境等等),前提是拥有目的环境的读写权限,有的环境不会自动登录(比如139),可通过配置工具调用批处理文件自动登录,比如139.bat
    @echo off
    
    net use \\172.25.32.139 密码 /USER:用户名

    选中72或139时会自动调用相应的登录批文件文件进行自动登录

    选中备份会在覆盖文件之前进行备份,备份文件在目标路径下建立backup文件夹并生成css文件名+日期.css(或图片)的文件

  9. 拖进来图片文件时,如未选中拷到72及拷到139会生成如下字符串
    <img
    src="data:image/png;base64,[base64 string]">

    选中拷到72或拷到139会拷贝至72及139

  10. 复选框是否默认选中可在配置文件中配置,具体看配置文件中的注释

后续开发计划

  1. 圆角等css3属性半自动生成,那些纠结的“-moz-”、“-webkit-”写一个就好,其他的工具生成,一是减少出错几率,二是省事,比如由
    -moz-border-radius:3px;

    生成

    -moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;

    大家都是用firefox开发吧,开发阶段直接写“-moz-”的就好

  2. css变量等等,基于CSS Wish List(偶们组之前的另外一个美女raina有翻译过,不过她的网站暂时打不开了,网址以后补上),Nicole Sullivan又整理了份css变量标准,正好可以参考

你有想法也可直接与我联系,工具随后发布,文档先行:)


10
七 10

Building Performance Into the New Yahoo! Homepage

via Building Performance Into the New Yahoo! Homepage by Nicholas Zakas, Yahoo!


10
七 10

background:url(#)的性能问题

很久之前写了使用 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);

29
六 10

[招聘]UI设计师

深圳华为(有可能是其子公司)

  1. 3年以上设计经验
  2. 本科 + 英语CET-4(必需)
  3. 懂html/css/js
  4. 懂交互

待遇不错,急招!(上次招前端没好人选,后面找了外包公司,汗~)

简历至:hungjunling@huawei.com

根据电话记录整理(让他发邮件给我具体要求,说是公司有么斯限制),有疑问邮件联系


17
六 10

How IE9 Determines Document Mode


07
六 10

HttpWatch 7.0 license 下载

上篇提到了获得了license的事情,鉴于对现在的我和周遭的人价值不大,不如共享,注意8月29号过期!

下载HttpWatch 7.0 license

能用最好,不能用买正版克:)


28
五 10

HttpWatch 7.0

前些天不知哪个feed反刍,看到老赵几年前发的这篇《意外得到了一个免费的HttpWatch Professional的License》,是不是在预示着什么?

今天向往常一样Google Reader,看到httpwatch 7.0搞发布活动HttpWatch 7.0: Spot the Differences!,于是就简单掺和了一下,没想到抢了沙发,license也到手了。

httpwatch做个广告,原因嘛你懂的

7.0增加了4个新功能

2010-6-7正式发布,期待~


23
五 10

Html5

via Html5