---
title: "firefox ellipsis hack has a condition"
author: "lerluc"
date: "2011-01-31T17:33:48Z"
tags: ["Blog", "CSS", "Firefox", "XML"]
categories: ["Web前端"]
slug: "firefox-ellipsis-hack-has-a-condition"
draft: false
lastmod: "2011-01-31T17:52:49Z"
id: 900457
url: "https://lerluc.iteye.com/blog/900457"
---

通常做firefox的\[i]\[u]文字溢出显示省略号\[/u]\[/i]会用xul的hack，但是有个条件如果没有满足就会失效，使内容变成空白。 这个条件是: \[quote]引用包含-moz-binding的css的页面必须与该css文件同域，并且也要和ellipsis的xml文件同域\[/quote] 也就是说下面这种情况会失效: \[quote]http://\[b]domain1\[/b].company.com/some-page.htm \[quote] This is a very very very very very very very very very very long sentence\[/quote]\[/quote] \[quote]http://\[b]domain2\[/b].company.com/public/css/ellipsis.css \[quote].ellipsis { \[b]-moz-binding: url(ellipsis.xml#ellipsis);\[/b] display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-wrap: normal; line-height: inherit; }\[/quote]\[/quote] \[quote]http://\[b]domain2\[/b].company.com/public/css/ellipsis.xml \[code="xml"] \[/code]\[/quote] 在有些部署场景，静态文件和引用页面的路径不是\[b]全域名匹配\[/b]的，比如静态文件会部署到不同次级域名的CDN，这种情况下就只能把ellipsis.css的内容以style形式写在页面里了 原文: http://mattlaine.com/blog/?p=49