在IE浏览器中模拟实现图片CSS的 max-width

非IE浏览器:

.post-body img {max-width:400px;}

IE:

.post-body img {
max-width:400px;
width: expression(this.width > 400 ? 400: true);
}

非IE浏览器:

.post-body img {max-width:95%;}

IE:

无法实现百分比的最大值

特别说明:

如果图片放在一个容器中时, 即使设置了容器的max-width值, 也需要设置图片的max-width值, 否则图片还是会撑开容器的尺寸.

#sidebar {width:220px;
width: expression(this.width > 220 ? 220: true);
}

#sidebar img {max-width:200px;
width: expression(this.width > 200 ? 200: true);
}

来源: http://phydeaux3.blogspot.com/2006/01/max-width-and-faking-it-for-ie.html

Some tips for MOSS or WSS developer

  • Avoid empty catch blocks and use error logging instead.
  • Use the ‘as’ operator to cast reference types instead of a type cast. This saves you a NullReferenceException in case of an invalid cast.
  • Use the TryParse methods to convert strings to value types instead of the Convert class.
  • Everything placed in a 12-hive sub folder should have it’s custom folder (such as Application name) – except for the Xml folder.
  • Avoid Access Denied errors using the SPWeb.GetSubWebsForCurrentUser() instead of SPWeb.Webs property.
  • Use the SPSite.OpenWeb(string, bool) overload to open a site from user input or check the Url property of SPWeb after opening. Otherwise you cannot be sure that you have opened the correct site.
  • Use Uri and UriBuilder class to work with URL whenever possible.
  • Use SPUrlUtility to work with url’s. It has methods to combine urls and more.
  • Never use the SPList.GetItemById. This performs really badly on bigger lists. Either use a SPQuery or the cached methods of the PortalSiteMapProvider.
  • Check list existence prior to using it. Requires a foreach over the Web’s SPListCollection (remember to break when found). Consider to use the ListsForCurrentUser property.
  • Avoid duplicating logic… Create code libraries with general methods and classes, instead of having the same method/logic in multiple classes/projects.
  • Use try/catch statements when reading/writing from ressources, and handle them gracefully instead of throwing them to end users.
  • Use stringbuilder to concatenate strings.
  • Proper use of Dispose() on disposable sharepoint objects as SPWeb and SPSite.
  • Use the buildin functionality in Visual Studio to format documents (CTRL+K, CTRL+D)
  • When writing and reading to/from a SharePoint List, create a DAL for doing these operations.
  • Use variables (constants) and refer to these, when using strings in the code.