0

我正在尝试将 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没有被解决。

4

2 回答 2

1

根据文档,PIE 仅识别速记样式。因此,您需要将border-radius 与每个角的速记值一起使用,而不是使用单独的border-xy-radius 属性。

http://css3pie.com/documentation/known-issues/#shorthand

http://css3pie.com/documentation/supported-css3-features/#border-radius

于 2012-02-14T18:15:28.907 回答
1

试试这个,我刚刚修改了你的代码:

URLMappings.groovy

class UrlMappings {
    static mappings = {
        "/$controller/$action?/$id?"{
            constraints {
                // apply constraints here
            }
        }
        "/"(controller:'home')
        "500"(view:'/error')
        "403"(view:'/login/denied')
        "/static/PIE.htc"(controller: 'home',action: 'css3pie') // <== see here
    }
}

HomeController.groovy

import grails.plugins.springsecurity.Secured
import org.springframework.core.io.Resource

@Secured("IS_AUTHENTICATED_FULLY")
class HomeController {

    def grailsApplication

    def index = { }

    def css3pie() {
        Resource pieHTC = grailsApplication.mainContext.getResource('css/PIE.htc') // <== see here
        response.contentType = 'text/x-component'
        response.outputStream << pieHTC.file.text
        response.outputStream.flush()
    }
}
于 2012-06-19T09:53:12.600 回答