我正在尝试将 css3pie 与 Grails 应用程序集成。根据说明,我需要做的就是:
- 将 PIE.htc 文件放在服务器上的某个位置
- 将以下内容添加到每个相关的 CSS 规则中
behavior: url(path/to/PIE.htc);
为了简化计算 PIE.htc 的路径,我将文件放在web-app/js/PIE.htc
. 然后我定义了以下 URL 映射
"/PIE.htc"(controller: 'home', action: 'css3pie')
由操作处理:
class HomeController implements ApplicationContextAware {
private ResourceLoader resourceLoader
void setApplicationContext(ApplicationContext applicationContext) {
this.resourceLoader = applicationContext
}
def css3pie() {
log.debug "css3pie HTC file requested"
Resource pieHTC = resourceLoader.getResource('/js/PIE.htc')
response.contentType = 'text/x-component'
response.outputStream << pieHTC.file.text
response.outputStream.flush()
}
}
如果您导航到http://summer-festivals.cloudfoundry.com/PIE.htc该文件已提供,因此一切似乎都在工作。然后我将该behavior
属性添加到一些 CSS 规则中,以查看它是否有效,例如
.roundBottomLeft {
border-bottom-left-radius: 10px;
-moz-border-radius-bottomleft: 10px;
behavior: url(/PIE.htc);
}
.roundBottomRight {
border-bottom-right-radius: 10px;
-moz-border-radius-bottomright: 10px;
behavior: url(/PIE.htc);
}
这应该围绕菜单的右下角和左下角,但是如果您在 IE8 中查看主页,您会发现它不起作用。
我似乎在解析PIE.htc
文件路径时出现问题,因为我在css3pie
上面的操作中设置了一个断点,但断点从未被命中。为什么路径PIE.htc
没有被解决。