更改“当前”的链接属性进入菜单 [英] Changing link properties for "current" entry on menu

查看:64
本文介绍了更改“当前”的链接属性进入菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我网站的菜单中,我已在当前​​页面的链接中插入了''class =" current"''。

。所以这个链接看起来很像链接:


< li>< a href =" index.php" class =" current"> Home< / a>< / li>


用于格式化菜单链接的CSS是:


#menu a:悬停{

背景颜色:#E00080;

颜色:白色;

}

#menu a:有效{

背景颜色:#E00080;

颜色:白色;

}


#menu li li a {

display:block;

color:white;

background-color :#C00080;

宽度:100%;

填充:0.5em 0.5em 0.5em 2em;

text-decoration:none;

border-bottom:1px solid #fff;

font-weight:normal;

font-size:75%;

}


和当前链接:


..当前{

背景颜色:红色;

}


但格式没有出现。


有谁知道我做错了什么?如果您想看看完整的网站,请访问:

http://holly.sillyfamily.org/


感谢您的帮助,


Don


PS如果您有任何建议,请随时提供。

一般配色方案是不可协商的(毕竟我的女儿是

)。虽然,我可能会编写一些备用样式表。

Within the menu for my site, I have inserted ''class="current"'' within
the link for the current page. So the link looks somthing link:

<li><a href="index.php" class="current">Home</a></li>

The css for formatting the menu links is:

#menu a:hover {
background-color: #E00080;
color: white;
}

#menu a:active {
background-color: #E00080;
color: white;
}

#menu li li a {
display: block;
color: white;
background-color: #C00080;
width: 100%;
padding: 0.5em 0.5em 0.5em 2em;
text-decoration: none;
border-bottom: 1px solid #fff;
font-weight: normal;
font-size: 75%;
}

and for the "current" link:

..current {
background-color: red;
}

But the formatting does not show up.

Does anyone have any idea what I''m doing wrong? If you would like to
look at the complete site, go to:

http://holly.sillyfamily.org/

Thank you for your help,

Don

PS If you have any suggestions, please feel free to offer them. The
general color scheme is non-negotiable though (it''s for my daughter
after all). Though, I might work up some alternate stylesheets.

推荐答案

Don G写道:
Don G wrote:
#menu a :hover {background-color:#E00080; }
和当前链接:
.current {background-color:red; }
但是格式化没有出现。
#menu a:hover { background-color: #E00080; }
and for the "current" link:
.current { background-color: red; }
But the formatting does not show up.




最具体的选择器获胜。 .current不太具体,然后#menu a:hover。

http://www.w3.org/TR/CSS2/cascade.html#specificity


-

David Dorward< http://blog.dorward.me.uk/> < http://dorward.me.uk/>

Home是〜/ .bashrc的地方



Most specific selector wins. .current is less specific then #menu a:hover.

http://www.w3.org/TR/CSS2/cascade.html#specificity

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


* Don G * < ma ****** @ yahoo.com>:
*Don G* <ma******@yahoo.com>:

在我的网站的菜单中,我在当前页面的链接。


为什么?为什么有人想要转到当前页面?它只是令人困惑

人。

< li>< a href =" index.php"类= QUOT;电流">家庭和LT; / A>< /锂>


为什么index.php? " ./& QUOT;或/似乎合乎逻辑。


< li>< a>主页< / a>< / li>


#menu a {

背景颜色:红色;

颜色:白色;

}

#menu a:link,#menu a:访问{

背景颜色:#C00080;

}

#menu a:悬停{
background-color: #E00080;
}
#menu a:活跃{
背景颜色:#E00080;
}

Within the menu for my site, I have inserted ''class="current"'' within
the link for the current page.
Why? Why would anyone want to go to the current page? It''s just confusing
people.
<li><a href="index.php" class="current">Home</a></li>
Why "index.php"? "./" or "/" seem logical.

<li><a>Home</a></li>

#menu a {
background-color: red;
color: white;
}
#menu a:link, #menu a:visited {
background-color: #C00080;
}
#menu a:hover {
background-color: #E00080;
}
#menu a:active {
background-color: #E00080;
}




或类似的东西。


-

明智的这么简单。试想

愚蠢的说法并反过来说。



Or something like that.

--
It''s so simple to be wise. Just think of
something stupid to say and say the opposite.


>为什么?为什么有人想要转到当前页面?它只是
> Why? Why would anyone want to go to the current page? It''s just
令人困惑的人。


为什么,好吧,我不想更改每个页面的菜单,删除链接

到当前页面,但我想区分来自其他链接的

当前页面的链接,以便用户通过查看菜单知道他们所在的页面



为什么index.php? " ./& QUOT;或/看似合乎逻辑


为什么不呢?它真的有所作为吗?我是为了保持一致性。

菜单中的其余链接指定了文件名,所以我也指定了

链接到index.php。有没有充分的理由不这样做?

< li>< a>主页< / a>< / li>

#menu a {
background-color:red;
color:white;
}
#menu a:link,#menu a:visited {
background-color:#C00080;
}
confusing people.
Why, well, I don''t want change the menu for each page removing the link
to the current page, but I would like to differentiate the link for the
current page from the rest of the links so the user can know which page
they are on by looking at the menu.
Why "index.php"? "./" or "/" seem logical.
Why not? Does it really make a difference? I did it for consistency.
The rest of the links in the menu specify a filename so I specified the
link to index.php as well. Is there a good reason to not do it?
<li><a>Home</a></li>

#menu a {
background-color: red;
color: white;
}
#menu a:link, #menu a:visited {
background-color: #C00080;
}
#menu a:hover {
background-color:#E00080;
}
#menu a:active {
背景颜色:#E00080;
}
#menu a:hover {
background-color: #E00080;
}
#menu a:active {
background-color: #E00080;
}



或类似的东西。


Or something like that.




我是包括使用PHP来帮助进行网站管理的菜单,并且它很容易添加''class =" current"''。但是,我不知道如何将b
删除当前页面链接的href,这就是为什么我问了我问的问题。所以,你知道一种方法来删除href使用

PHP吗?


谢谢,


Don



I''m including the menu using PHP to help with site management, and it is
easy to add ''class="current"''. However, I am not aware of how I might
remove the href for the link to the current page, which is why I asked
the question I asked. So, do you know of a way to remove the href using
PHP?

Thanks,

Don


这篇关于更改“当前”的链接属性进入菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆