css path not working in zend
i created a controller and actions in zend. if i type "http://lo开发者_如何学Pythoncalhost/cms/public/controller" then the css file is loaded correctly but if i type "http://localhost/cms/public/controller/action"
then headlink appears like
href='http://localhost/cms/public/controller/css/style.css" and it does not work. Please help me!!
this is the correct way to add css & javascript to ZF Application
<?php
$this->headLink()->appendStylesheet($this->baseUrl("css/reset.css"))
->appendStylesheet($this->baseUrl("css/text.css"))
->appendStylesheet($this->baseUrl("css/960.css"))
->appendStylesheet($this->baseUrl("css/demo.css"));
echo $this->headLink();
$this->headScript()->appendFile($this->baseUrl("js/jquery-1.4.2.min"))
->appendFile($this->baseUrl("js/jquery-ui-1.8.2.custom.min"));
echo $this->headScript();?>
You have your css path set to "css/style.css". Set the css path relative to the root path. If your css is in /html/style/css/style.css, the link would be "/style/css/style.css"
Always remember the leading slash and make the static paths relative to the root dir(of the website).
精彩评论