我有一個Html超鏈接。我需要將此超鏈接鏈接到另一個頁面。當我將鼠標放在鏈接上時。它應該顯示圖像。 如何做到這一點HTML超鏈接鼠標在圖像上
0
A
回答
3
這取決於您需要顯示圖像的位置。
a:link
{
background-image:none;
}
a:hover
{
background-image:url('images/icon.png');
background-repeat:no-repeat;
background-position:right;
padding-right:10px /*adjust based on icon size*/
}
我做這一關頂:如果您正在尋找沿着圖標的旁邊或鏈接在後方的東西,你可以對鏈接的懸停狀態使用背景圖像通過CSS實現這一目標我的頭,所以你可能需要做一些小的調整。
如果您想在頁面上的其他位置顯示圖像,可以使用javascript在鏈接的mouseover事件中隱藏/顯示圖像。
如果這不能解決您的問題,也許您可以提供一些額外的信息來幫助指導每個人正確的答案。
0
你可以做到這一點使用JavaScript ..
這將創建一個跟隨你的DIV或元素懸停鼠標一個正方形。
創建這裏這些內容.js文件:
var WindowVisible = null;
function WindowShow() {
this.bind = function(obj,url,height,width) {
obj.url = url;
obj.mheight = height;
obj.mwidth = width;
obj.onmouseover = function(e) {
if (WindowVisible == null) {
if (!e) e = window.event;
var tmp = document.createElement("div");
tmp.style.position = 'absolute';
tmp.style.top = parseInt(e.clientY + 15) + 'px';
tmp.style.left = parseInt(e.clientX + 15) + 'px';
var iframe = document.createElement('iframe');
iframe.src = this.url;
iframe.style.border = '0px';
iframe.style.height = parseInt(this.mheight)+'px';
iframe.style.width = parseInt(this.mwidth)+'px';
iframe.style.position = 'absolute';
iframe.style.top = '0px';
iframe.style.left = '0px';
tmp.appendChild(iframe);
tmp.style.display = 'none';
WindowVisible = tmp;
document.body.appendChild(tmp);
tmp.style.height = parseInt(this.mheight) + 'px';
tmp.style.width = parseInt(this.mwidth) + 'px';
tmp.style.display = 'block';
}
}
obj.onmouseout = function() {
if (WindowVisible != null) {
document.body.removeChild(WindowVisible);
WindowVisible = null;
}
}
obj.onmousemove = function(e) {
if (!e) e = window.event;
WindowVisible.style.top = parseInt(e.clientY + 15) + 'px';
WindowVisible.style.left = parseInt(e.clientX + 15) + 'px';
}
}
}
然後在你的HTML執行以下操作:
包含的js文件
<script type="text/javascript" src="myfile.js"></script>
把你的網頁:
<script type="text/javascript">
var asd = new WindowShow();
asd.bind(document.getElementById('go1'),'IMAGE URL HERE!',400,480);
</script>
這是在HTML的完全實現:
<html>
<head>
<title>test page</title>
<style>
div.block { width: 300px; height: 300px; background-color: red; }
iframe { border: 0px; padding: 0px; margin: 0px; }
</style>
<script type="text/javascript" src="window_show.js"></script>
</head>
<body>
<div id="go1" style="background-color: red; width: 200px; height: 200px;"></div>
<script type="text/javascript">
var asd = new WindowShow();
asd.bind(document.getElementById('go1'),'IMAGE URL HERE!',400,480);
</script>
</body>
再見!
+0
我覺得他想的圖像顯示在頁面上,而不是下面的鼠標光標。 – nickf 2008-11-14 02:16:15
0
您可以使用jQuery很容易地做到這一點:
$("li").hover(
function() {
$(this).append($("<img src="myimage.jpg"/>"));
},
function() {
$(this).find("img:last").remove();
}
);
這是實際測試過一些更全面的例子: http://docs.jquery.com/Events/hover
相關問題
- 1. HTML超鏈接圖像僅在超鏈接時消失?
- 2. 如何更改鼠標懸停在圖像上超鏈接的顏色?
- 3. 在圖像上鼠標懸停時顯示超鏈接和彈出窗口!
- 4. 沒有超鏈接的li鼠標懸停的圖像彈出?
- 5. HTML超鏈接圖像移動等
- 6. 超鏈接圖像
- 7. 超鏈接圖像
- 8. 如何更改鼠標上的鏈接圖像上jquery
- 9. iOS使用超鏈接和圖像呈現HTML標記
- 10. 當鼠標懸停在超鏈接上時顯示圖片縮略圖(jQuery,CSS?)
- 11. 鼠標懸停在超鏈接上的小說明窗口
- 12. 圖像鏈接上的鼠標按下檢測
- 13. 鏈接/鼠標移到背景圖像上IE 8
- 14. 鼠標移過鏈接後,HTML超鏈接保持顏色變化
- 15. 圖像沒有超鏈接
- 16. 應用超鏈接圖像
- 17. WPF超鏈接圖像
- 18. 圖像交換超鏈接
- 19. 如何超鏈接圖像
- 20. 控制圖像,標題和超鏈接像在VS
- 21. JavaScript:在鏈接上拖動鼠標
- 22. 鼠標懸停的html鏈接
- 23. 變化圖像鏈接時,將鼠標懸停在鏈接的CSS
- 24. jQuery將鼠標懸停在動態鏈接後更改圖像
- 25. 超鏈接圖像周圍的HTML,但在瀏覽器
- 26. 圖像超鏈接不能在HTML中工作
- 27. 在圖像下方設置超鏈接
- 28. 圖片上的超鏈接
- 29. 文本超鏈接褪色成圖像也超鏈接
- 30. 當超鏈接到圖像時,超鏈接的位置
+1 - 這是迄今爲止做懸停的最簡單的方法。我已經看到了* CSS * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * – nickf 2008-11-14 02:18:04