【发布时间】:2025-12-04 11:15:02
【问题描述】:
我为我的网站创建了一个 header.php。 对于我的菜单,我创建了 5 个按钮。 当我按下一个按钮时,它会将我重定向到与之关联的页面上。 到目前为止一切都很好。
我想要的是,在当前页面上,与之关联的页面的按钮更改为其他颜色或背景图像。
我不知道我们能不能做到这一点,我是否能很好地解释自己。
这里是我的 header.php
<div id="main_menu">
<div id="menu_blog"><button onclick="location.href='blog.html'"><h1>Trucs/Astuces</h1></button></div>
<div id="menu_contact"><button onclick="location.href='/contact.php'"><h1>Contact</h1></button></div>
<div id="menu_soumission"><button onclick="location.href='/soumission.php'"><h1>Soumission</h1></button></div>
<div id="menu_realisation"><button onclick="location.href='/realisations.php'">
<h1>Réalisations</h1></button></div>
<div id="menu_service"><button onclick="location.href='/services.php'">
<h1>Services</h1></button></div>
<div id="menu_a_propos"><button onclick="location.href='/a_propos.php'"><h1>L'entreprise</h1></button></div>
</div>
【问题讨论】:
-
为什么使用按钮而不是链接? - 另外,您使用的是 WordPress 之类的东西 - 还是直接使用 php?