实用的Dos命令

by kevin 23. 二月 2014 15:38 >
查看DNS缓存 ipconfig /displaydns 清除DNS缓存 ipconfig /flushdns

开发杂记:如何处理google chrome最小字号的问题

by kevin 16. 十二月 2013 14:15 >
最近在改版65emall的时候,碰到一个很棘手的问题,Chrome浏览器有个最小字号设置,就是当字号小于最小字号时,就会自动调整为自动调整为最小的字号。如下图: 在中文版的Chrome中,默认的最小字号是12; 在英文版的Chrome中,默认的最小字号是10。 1: -webkit-text-size-adjust:none; 网上很多都建议使用上面这样的语法来实现,但在高版本的Chrome中,这个语法已经无效了。 所以使用 -webkit-transform: 代码如下: 1: .font-size8 { font-size: 8px;} 2: .font-size9 {font-size: 9px;} 3: .font-size10 {font-size: 10px;} 4: @media screen and (-webkit-min-device-pixel-ratio:0) { 5: .font-size8 { 6: font-size: 12px; 7: margin-top: 1px; 8: -webkit-transform: scale(0.83); 9: } 10: .font-size9 { 11: font-size: 12px; 12: margin-top: 2px; 13: -webkit-transform: scale(0.86); 14: } 15: .font-size10 { 16: font-size: 12px; 17: margin-top: 2px; 18: -webkit-transform: scale(0.92); 19: } 20: } 注意一下 为了能同时兼容中英文Chrome,10号,11号也要这样缩小 这个比例不是简单的等比例缩小,比如9号字,的缩放比例就不是0.75 另外需要注意的一点是,长度,高度,还是会按照10或者12号字来计算,所以,最好在外层在加个div作为容器。 1: <div> 2: <div class="font-size9">font-size:9px</div> 3: </div>

开发杂记:让小于12号的字在google chrome中显示

by kevin 8. 十一月 2013 13:40 >
做为一个非专业的Css编写人员,一不小心,就可以踩到坑。 觉得小于12号的字不利于阅读,所以google chrome小于12号的字,都会被修正为12号。 google了下,据说,随着浏览器版本的升级,处理的方案还不一样。 整体的代码如下: 1: * { 2: -webkit-text-size-adjust: none; 3: -webkit-transform-origin-x: 0; 4: -webkit-transform: scale(0.8333333333333334); /* 10/12=0.8333333333333334) */ 5: }

开发杂记:z-index的那些坑

by kevin 22. 十月 2013 13:58 >
要实现my cart那样的边框效果,很自然的想到 上面一个div, 下面一个div, 上面那个div的z-index比下面的这个大, 下面这个div往上移1px。 然后,悲剧就开始了。。。 总结了一下,基本上是以下几个坑: z-index 仅能在定位元素上奏效,就是要求该元素设置 position:xxxx,否则z-index无效。 如果元素内嵌于li,那么li需要设置 position:relative 上面的div需要设置background,否则无法遮住下面的div 主要代码如下: 1: <li style="position:relative" id="cart" > 2: <div style="width: 100px; height:23px; position: relative; z-index: 2; background-color: white; border: 1px solid #d3d3d3;"></div> 3: <div style="position: absolute; width: 100px; z-index: 1; top: 22px; background-color: white; border: 1px solid #d3d3d3; "> 4: </div> 5: </li>

开发杂记:RequestValidationMode

by kevin 30. 八月 2013 13:56 >
碰到一个管理后台项目,使用的是Asp.net 2.0时候的WebForm,但项目已经升级到Asp.net 4.0了。 今天碰到一个小意外,测试那边报了一个HttpRequestValidationException,在.net 2.0时代,将页面的ValidateRequest设置为false,或者在Web.Config里面设置<pages validateRequest="false" />,升级到.net 4.0后,验证模式也已经升级了。所以如果采用默认的设置,就会报HttpRequestValidationException,解决的办法是,将RequestValidationMode设置为2.0,代码如下: 1: <system.web> 2: <compilation debug="true" targetFramework="4.0"/> 3: <httpRuntime requestValidationMode="2.0" /> 4: <pages validateRequest="false"></pages> 5: </system.web> 关于RequestValidationMode,有两个值,默认是4.0 4.0 (the default). The HttpRequest object internally sets a flag that indicates that request validation should be triggered whenever any HTTP request data is accessed. This guarantees that the request validation is triggered before data such as cookies and URLs are accessed during the request. The request validation settings of the pages element (if any) in the configuration file or of the @ Page directive in an individual page are ignored. 2.0. Request validation is enabled only for pages, not for all HTTP requests. In addition, the request validation settings of the pages element (if any) in the configuration file or of the @ Page directive in an individual page are used to determine which page requests to validate.

C#小技巧-持续更新

by kevin 29. 八月 2013 22:19 >
字符串转换为日期 1: DateTime.ParseExact(MYCulturDate, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); 获取某个文件夹下的所有文件 1: Directory.GetFiles("Path", "*.*", SearchOption.AllDirectories)

开发杂记:C#压缩JPG文件

by kevin 20. 八月 2013 21:44 >
最近在开发65emall的时候,发现产品的缩略图每个都有几十KB,检查了下,发现,在生成缩略图的时候,代码里只是设置了InterpolationMode,如下 1: g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low; 其实这样的压缩,非常有限,所以文件还是非常大。 其实,要真正压缩jpg文件,还是要降低图片的质量,这里我们设置了50%,结果图片大小缩小了80-90%。 具体的代码如下 1: private static ImageCodecInfo GetEncoder(ImageFormat format) 2: { 3: ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders(); 4: foreach (ImageCodecInfo codec in codecs) 5: { 6: if (codec.FormatID == format.Guid) 7: { 8: return codec; 9: } 10: } 11: return null; 12: } 13:  14: private static void CreateImage(int oldWidth, int oldHeight, int limitWidth, int limitHeight, 15: System.Drawing.Image oldImage, string path, string fileName) 16: { 17: if (!System.IO.Directory.Exists(path)) 18: { 19: System.IO.Directory.CreateDirectory(path); 20: } 21: int createWidth, createHeight; 22: ImageSize(oldWidth, oldHeight, limitWidth, limitHeight, out createWidth, out createHeight); 23:  24: System.Drawing.Bitmap createImage = new System.Drawing.Bitmap(createWidth, createHeight); 25: System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(createImage); 26: g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low; 27: g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; 28: g.Clear(System.Drawing.Color.Transparent); 29: g.DrawImage(oldImage, new System.Drawing.Rectangle(0, 0, createWidth, createHeight), 30: new System.Drawing.Rectangle(0, 0, oldImage.Width, oldImage.Height), 31: System.Drawing.GraphicsUnit.Pixel); 32: ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg); 33: System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality; 34: EncoderParameters myEncoderParameters = new EncoderParameters(1); 35: EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 50L); 36: myEncoderParameters.Param[0] = myEncoderParameter; 37: createImage.Save(path + fileName, jgpEncoder, myEncoderParameters); 38: g.Dispose(); 39: createImage.Dispose(); 40: } 参考资料: How to: Set JPEG Compression Level How to: Use Interpolation Mode to Control Image Quality During Scaling

开发杂记:给placeholder设置样式

by kevin 15. 八月 2013 13:23 >
目前,没有统一的CSS语法可以来设置placeholder的样式,但IE,Firefox, Chrome/Safari都提供了各自的语法,具体如下。 1: ::-webkit-input-placeholder { color:#f00; } 2: ::-moz-placeholder { color:#f00; } /* firefox 19+ */ 3: :-ms-input-placeholder { color:#f00; } /* ie */ 4: input:-moz-placeholder { color:#f00; } /* firefox */

开发杂记:DIV垂直居中

by kevin 23. 七月 2013 22:26 >
这个话题挺有意思的,网上给出了很多的解决方案,感觉只有一种方法比较实用。 1: <div style="width:150px; height:150px;display:table-cell; vertical-align:middle;"> 2: <div style="width:150px;"> 3: <div> 4: </div> 其实,如果不考虑IE,并不需要嵌在内部的div。 另外PS另外一个小技巧:img的等比例缩放大小。 1: <img style="max-height:150px; max-width:150px;" src="">

开发杂记:如何使用google字体

by kevin 26. 六月 2013 13:56 >
前段时间,65emall上请设计公司设计的活动页面使用了google字体,效果是挺好看的,问题是google字体只提供woff文件,所以在ie浏览器下无法正常浏览,要兼容ie的各个版本需要将woff文件转换成eot,tff等文件,找了很多个网站或是技术问题,或者是版权问题,都无法直接转换woff文件,最后在颠_颠帮助下找到了everythingfonts。问题就可以解决了。 1 将google字体下载下来 2 通过everythingfonts将woff文件转换成tff文件 3 再通过其他的在线字体转换网站转换成eot等文件格式 4 然后是@font-face来搞定   PS: 1 everythingfonts可能需要翻墙。 2 转换后的字体,字宽可能会不一样,可以使用font-weight来调整一下。 3 版权问题,谁要知道怎么处理,更我说一下。 4 http://www.zhuan-huan.com/font-converter.php 这里好像也可以转换,未验证。 实例下载

打赏请我喝果汁咯

支付宝 微信

关于我

80后,单身,平庸的程序员。

喜欢看书,乐于交友,向往旅游。

遇建Kevin

FluentData交流群:477926269

Fluentdata