我在我的标题中添加了一个“我的帐户”链接和一个愿望清单链接。它在主页上显示正常,但是当我继续显示任何其他页面时,图像不再显示,我看到的只有Alt文本。
有人可以帮我调整我的代码,以便在所有页面上正确显示相同的图像吗? : - )
我试过这样做,以便通过让一张图像低于另一张图片,图片在悬停时改变颜色......
PHP:
<div id="myaccount">
<a href="wordpress/my-account"><img class="bottom" src="wp-
content/themes/mt_theme/images/my_account_hover.png" alt="My
Account"/>
<img class="top" src="wp-content/themes/my_theme/images/my_account.png" alt="My Account"/>
<p class="icotext">My Account</p>
</a>
</div>
<div id="wishlist">
<a href="wishlist"><img class="bottom2" src="wp-content/themes/smy_theme/images/wishlist_hover.ico" alt="Wishlist"/>
愿望清单
CSS:
#myaccount{
position: relative;
margin: 0 auto;
}
#myaccount img {
position:absolute;
left:900px;
top: -20px;
Height: 50px !important;
width: 50px !important;
}
a:hover img.top {
opacity:0;
}
.icotext{
position: absolute;
left: 890px;
top: 28px;
color: #000000
}
a:hover .icotext{
font-weight: bold;
left: 888px;
}
#wishlist{
position: relative;
margin: 0 auto;
}
#wishlist img {
position:absolute;
left:990px;
top: -20px;
Height: 50px !important;
width: 50px !important;
}
.icotext2{
position: absolute;
left: 992px;
top: 28px;
color: #000000
}
a:hover .icotext2{
font-weight: bold;
left: 990px;
}
a:hover img.top2 {
opacity:0;
}
img.bottom2 {
opacity:0;
}
a:hover img.bottom2 {
opacity:1;
}
img.bottom {
opacity:0;
}
a:hover img.bottom {
opacity:1;
答案 0 :(得分:1)
我猜其他网页正试图从另一个文件夹中获取图片。
src="wp-content/themes/my_theme/images/my_account.png"
您使用的相对地址被解释为“{current folder} / wp-content / ...” 尝试使用
src="/wp-content/themes/my_theme/images/my_account.png"
前面的/将被解释为“{site_root} / wp-content /..."