我想做一个div可点击,但在这里<div>我有另一个<div>也应点击或链接.
HTML
<a href="#">
<div class="box">
<div class="plus"><img src="aaa.jpg"/></div>
</div>
</a>
Run Code Online (Sandbox Code Playgroud)
CSS
.box{
float:left;
width:100px;
height:100px;
}
.plus{
float:left;
width:30px;
height:30px;
}
Run Code Online (Sandbox Code Playgroud)
我可以将两个<div>链接和不同的链接?
这是正确的方式使用div里面a href?
Sta*_*arx 27
不,分配给包含的链接<a>将分配给其中的每个元素.
而且,这不是正确的方法.你可以<a>表现得像<div>.
一个例子[演示]
CSS
a.divlink {
display:block;
width:500px;
height:500px;
float:left;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div>
<a class="divlink" href="yourlink.html">
The text or elements inside the elements
</a>
<a class="divlink" href="yourlink2.html">
Another text or element
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
Ada*_*low 21
从HTML5开始,允许在div周围包装链接.