2013-08-28 43 views
0

我有一個運行在我的普通HTML網站的背景圖片。我在我的背景圖片中添加了另一個網站的2個LOGOS。我如何創建一個透明的DIV和鏈接只有標誌的部分到我的網站更像是一個熱點,當我點擊標誌時,它應該打開一個新標籤並顯示網頁?任何幫助將不勝感激! :)鏈接一個透明的DIV

這是盒子的CSS,

#logobox1 { 
    width: 114px; 
    height: 28px; 
    Left: 1850; 
    top: 43;  
} 
#logobox2 { 
    width: 92px; 
    height: 40px; 
    left: 1857; 
    top: 40; 
} 
+0

請出示HTML也是如此。另外創建一個JSFiddle也會很棒。 – MitulP91

+0

好!給我一分鐘 –

+0

@ MitulP91看看黑點是我想要的標誌.... http://jsfiddle.net/ –

回答

1

我想你想要的是一個錨標記<a>,而不是一個div。

我們在錨標籤上使用絕對定位,position: absolute;。爲了這個工作,它的元素應該使用相對定位,position: relative;。然後我們將錨點標記顯示爲阻止,display: block;,因此它會接受我們給出的尺寸。這當然是你圖片的尺寸。

除此之外,它是從包含元素的頂部和左側移動它,直到它處於正確的位置。

http://jsfiddle.net/UHTPx/1/

HTML

<div class="container"> 
    <a class="hitbox" href="google.com" target="_blank"></a> 
</div> 

我加邊框,爲了說明的目的各元件。

CSS

.container { 
    background: url('http://lorempixel.com/150/75/abstract/') no-repeat center center; 
    border: 1px dashed #DEDEDE; 
    height: 400px; 
    margin: 0 auto; 
    position: relative; 
    width: 400px; 
} 
.hitbox { 
    border: 1px dotted red; 
    height: 75px; 
    left: 50%; 
    margin-left: -75px; 
    margin-top: -37.5px; 
    position: absolute; 
    top: 50%; 
    width: 150px; 
}