兼容IE6、7、8和FF的省略号
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <BODY><style type="text/css">#wrap{width:560px;border:1px solid #333;/* 以下为控制省略号的样式 */overflow:hidden;text-overflow:ellipsis;white-space:nowrap;/* 以下是FF特有属性,需要XUL文件支持 */-moz-binding:url("ellipsis.xml#ellipsis");}</style><div id="wrap">Always in center!Always in center!Always in center!Always in center!Always in center!Always in center!Always in center!Always in center!Always in center!Always in center!</div> </BODY></html>支持FF所需要的ellipsis.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8"?><bindingsxmlns="http://www.mozilla.org/xbl"xmlns:xbl="http://www.mozilla.org/xbl"xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><binding id="ellipsis"> <content> <xul:description crop="end" xbl:inherits="value=xbl:text"><children/></xul:description> </content></binding></bindings>
IE下,对于loose.dtd的文档类型,span是不受width属性控制的,需要使用div
FF中,span都不受width属性影响
页:
[1]