影响 Firefox 中 CSS sprite 导航的表达式引擎路径/url

发布于 2024-11-25 22:29:15 字数 3130 浏览 1 评论 0原文

我目前正在将一个 HTML 站点放入 Expression Engine 中。该站点使用主体 ID 标签来驱动精灵导航,而不是当前/活动类。当我创建带有空白链接的网站索引时,导航显示正确。然而,当我将页面链接到适当的模板时,精灵位置都默认为导航的 a:link 位置中的最后一个精灵。当悬停时,链接将正确显示,单击时将我带到正确的位置并更改为正确的 a:focus/hover 位置。此行为会出现在 Firefox 中,但不会出现在 Safari 中。在 Safari 中,一切都按照我的预期显示。 我在本地安装上使用 Expression Engine 2.x。我也重新检查了频道网址和站点配置设置,但我不知道问题出在哪里。 任何想法将不胜感激。

这是我遇到的问题的视觉。 。第一行是导航在 Firefox 中的显示方式。第二行是当链接悬停在链接上时链接的外观。第三个是 Safari 中导航的呈现方式。

这是导航的 css:

/* navigation */
#nav    {
background: url("/img/nav-bg.gif") no-repeat top left;
position:absolute;
top:176px;
width:960px;
height:44px;
z-index:20;
}

ul#navlist {
position:relative;
height:35px;
width:512px;
padding-left:192px;
margin-top:4px;
overflow:hidden;
}


ul#navlist li   {
padding:0;
margin:0;
float:left;
margin:0px;
text-indent:-9999px;
list-style:none;
}

ul#navlist li a {
display:block;
background-image:url("/img/main-nav-sprite.jpg");
background-repeat:no-repeat;
overflow:hidden;
}

ul#navlist li a:link, #navlist a:visted {
display:block;
}

li#home a {
width:82px;
height:35px;
}

li#services a {
width:101px;
height:35px;
}

li#portfolio a {
width:105px;
height:35px;
}

li#blog a {
width:76px;
height:35px;
}

li#about a {
width:82px;
height:35px;
}

li#contact a {
width:65px;
height:35px;
}

li#home a:link, a:visited   {
background-position:0px 0px;
}

li#home a:hover, a:focus    {
background-position: 0px -35px;
}

li#services a:link, a:visited   {
background-position:-82px 0px;
}

li#services a:hover, a:focus    {
background-position: -82px -35px;
}

li#portfolio a:link, a:visited  {
background-position:-183px 0px;
}

li#portfolio a:hover, a:focus   {
background-position: -183px -35px;
}

li#blog a:link, a:visited   {
background-position:-288px 0px;
}

li#blog a:hover, a:focus    {
background-position: -288px -35px;
}

li#about a:link, a:visited  {
background-position:-364px 0px;
}

li#about a:hover, a:focus   {
background-position: -364px -35px;
}

li#contact a:link, a:visited    {
background-position:-447px 0px;
}

li#contact a:hover, a:focus {
background-position: -447px -35px;
}

/* Main Navigation Active States */
body#home-page ul#navlist li#home a {
background-position:0 -35px;
}

body#services-page ul#navlist li#services a {
background-position:-82px -35px;
}

body#folio-page ul#navlist li#portfolio a   {
background-position:-183px -35px;
}

body#blog-page ul#navlist li#blog a {
background-position:-288px -35px;
}

body#about-page ul#navlist li#about a   {
background-position:-364px -35px;
}

body#contact-page ul#navlist li#contact a   {
background-position:-447px -35px;
}
/* end */

这是我附加的 html 导航代码:

    <div id="nav">
    <ul id="navlist">
    <li id="portfolio"><a href="http://localhost:8888/portfolio" title="hue samples">portfolio</a></li>
    <li id="blog"><a href="http://localhost:8888/news" title="learn with us">blog</a></li>
    </ul>
    </div>
    <!-- ***nav -->

我也尝试使用 {path="template group/template"} 但结果相似。

I'm currently putting an HTML site into Expression Engine. The site uses the body ID tag to drive the sprite navigation rather than current/active classes. When I created the site index with blank links the navigation appeared correctly. However when I linked the pages to the appropriate templates the sprite positions all defaulted to the last sprite in the navigation's a:link position. When hovered the link would display properly and when clicked take me to the correct place and change to the correct a:focus/hover position. This behavior occurs in Firefox but not Safari. In Safari everything appears how I expected it to.
I'm using Expression Engine 2.x on a local installation. I've re-examined the channel urls and the site config settings as well but I've run out of ideas as to what the problem could be.
Any thoughts would be appreciated.

This is a visual of the issue I'm having. . The first line is what is how the nav appears in Firefox. The second row is how the link looks when a link is hovered over. The third is how the nav is rendered in Safari.

This is the css for the navigation:

/* navigation */
#nav    {
background: url("/img/nav-bg.gif") no-repeat top left;
position:absolute;
top:176px;
width:960px;
height:44px;
z-index:20;
}

ul#navlist {
position:relative;
height:35px;
width:512px;
padding-left:192px;
margin-top:4px;
overflow:hidden;
}


ul#navlist li   {
padding:0;
margin:0;
float:left;
margin:0px;
text-indent:-9999px;
list-style:none;
}

ul#navlist li a {
display:block;
background-image:url("/img/main-nav-sprite.jpg");
background-repeat:no-repeat;
overflow:hidden;
}

ul#navlist li a:link, #navlist a:visted {
display:block;
}

li#home a {
width:82px;
height:35px;
}

li#services a {
width:101px;
height:35px;
}

li#portfolio a {
width:105px;
height:35px;
}

li#blog a {
width:76px;
height:35px;
}

li#about a {
width:82px;
height:35px;
}

li#contact a {
width:65px;
height:35px;
}

li#home a:link, a:visited   {
background-position:0px 0px;
}

li#home a:hover, a:focus    {
background-position: 0px -35px;
}

li#services a:link, a:visited   {
background-position:-82px 0px;
}

li#services a:hover, a:focus    {
background-position: -82px -35px;
}

li#portfolio a:link, a:visited  {
background-position:-183px 0px;
}

li#portfolio a:hover, a:focus   {
background-position: -183px -35px;
}

li#blog a:link, a:visited   {
background-position:-288px 0px;
}

li#blog a:hover, a:focus    {
background-position: -288px -35px;
}

li#about a:link, a:visited  {
background-position:-364px 0px;
}

li#about a:hover, a:focus   {
background-position: -364px -35px;
}

li#contact a:link, a:visited    {
background-position:-447px 0px;
}

li#contact a:hover, a:focus {
background-position: -447px -35px;
}

/* Main Navigation Active States */
body#home-page ul#navlist li#home a {
background-position:0 -35px;
}

body#services-page ul#navlist li#services a {
background-position:-82px -35px;
}

body#folio-page ul#navlist li#portfolio a   {
background-position:-183px -35px;
}

body#blog-page ul#navlist li#blog a {
background-position:-288px -35px;
}

body#about-page ul#navlist li#about a   {
background-position:-364px -35px;
}

body#contact-page ul#navlist li#contact a   {
background-position:-447px -35px;
}
/* end */

This is my html nav code appended:

    <div id="nav">
    <ul id="navlist">
    <li id="portfolio"><a href="http://localhost:8888/portfolio" title="hue samples">portfolio</a></li>
    <li id="blog"><a href="http://localhost:8888/news" title="learn with us">blog</a></li>
    </ul>
    </div>
    <!-- ***nav -->

I tried using {path="template group/template"} as well but the result was similar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

窝囊感情。 2024-12-02 22:29:15

检查并确保您正确链接到样式表你的模板。

如果您的 CSS 是 ExpressionEngine 模板:

<link href="{stylesheet=template_group/template_name}" media="all" />

如果您的 CSS 是服务器上的文件:

<link href="{path=/css/screen.css}" media="all" />

如果您的样式表正确链接,则问题的唯一其他可能是样式表中到精灵的路径。

我更喜欢使用图像的绝对路径,因此它使维护变得容易:

#foo {
    background: url(/images/sprite.png) no-repeat left top;
}

要确认您的路径是否正确,请使用对您来说更舒服的方法,并使用以下方法查找错误:

  • Firefox 的 Firebug
  • Safari 的活动监视器或 WebKit Inspector
  • Chrome 的开发人员工具
  • Apache 的 错误日志

如果您可以发布一些代码示例,则可以更轻松地进一步排除您的问题。

Check to make sure that you're linking to stylesheets correctly in your templates.

If your CSS is an ExpressionEngine template:

<link href="{stylesheet=template_group/template_name}" media="all" />

If your CSS is a file on your server:

<link href="{path=/css/screen.css}" media="all" />

With your stylesheet(s) linked to correctly, the only other possibility to your problem would be the path to your sprite from within the stylesheet.

I prefer to use absolute paths to images, so it makes maintenance easy:

#foo {
    background: url(/images/sprite.png) no-repeat left top;
}

To confirm your paths are correct, use whichever method is more comfortable for you and look for errors using:

  • Firefox's Firebug
  • Safari's Activity Monitor or WebKit Inspector
  • Chrome's Developer Tools
  • Apache's error_log.

If you can post some code samples, it would make further troubleshooting your issue easier.

内心激荡 2024-12-02 22:29:15

查看您的 CSS,您在样式表中多次声明了一些相同的规则。因此,样式表中稍后出现的任何规则都将覆盖与同一选择器匹配的任何先前规则。

因此,您可以通过删除不必要的 :link:visited 等来极大地简化 CSS 伪类选择器 这将使调试图像精灵变得更加容易。

例如,考虑以下 HTML:

<div id="nav">
    <ul id="navlist">
        <li id="portfolio"><a href="#">portfolio</a></li>
    </ul>
</div>

相关 CSS 可以简化并合并为:

li#portfolio a {
    background-position: -183px 0;
    height: 35px;
    width: 105px;
}

li#portfolio a:hover {
    background-position: -183px -35px;
}

删除并消除 LVHA (LOVE HATE) CSS 中不需要的伪类 将大大降低调试的复杂性 问题。

Looking at your CSS, you're declaring some of the same rules multiple times in your stylesheet. As a result, whatever rules appear later in the stylesheet will override any previous rules matching the same selector.

Therefore, you can greatly simplify your CSS by removing the unnecessary :link, :visited, et al pseudo class selectors which will make debugging your image sprite much easier.

For example, consider the following HTML:

<div id="nav">
    <ul id="navlist">
        <li id="portfolio"><a href="#">portfolio</a></li>
    </ul>
</div>

The relevant CSS can be simplified and consolidated into:

li#portfolio a {
    background-position: -183px 0;
    height: 35px;
    width: 105px;
}

li#portfolio a:hover {
    background-position: -183px -35px;
}

Removing and eliminating the LVHA (LOVE HATE) pseudo classes from your CSS where they're not needed will drastically reduce the complexity debugging your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文