2017-09-16 11 views

答えて

0

JavaScriptを使用:

<div onclick="location.href='http://google.com/';" style="cursor: pointer;"</div> 

使用するdivクリッカブルを作るにaタグ:

#my-div { 
 
    background-color: #f00; 
 
    width: 200px; 
 
    height: 200px; 
 
} 
 
a.fill-div { 
 
    display: block; 
 
    height: 100%; 
 
    width: 100%; 
 
    text-decoration: none; 
 
} 
 
It is possible to make a link fill the entire div which gives the appearance of making the div clickable.
<div id="my-div"> 
 
    <a href="http://google.com/" class="fill-div"></a> 
 
</div>

+0

@helloデザインもしあなたのために私の答えが役に立ったら、答えを受け入れるか、アップしてください、ありがとう。 – aghilpro

1

があなたのdivにこの属性を追加します。

<div onclick="window.location = 'http://www.yoururl.com'"> 

目的のリンクに変更します。

関連する問題