< DIV>内部链接(< a href =">>)标记 [英] <DIV> inside link (<a href="">) tag

查看:299
本文介绍了< DIV>内部链接(< a href =">>)标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让div可点击,但在< div> 里面有另一个< div>

 <$ c> 

$ c>< a href =#>
< div class =box>
< div class =plus>< img src =aaa.jpg/>< / div>
< / div>
< / a>

CSS

  .box {
float:left;
width:100px;
height:100px;
}
.plus {
float:left;
width:30px;
height:30px;
}

我可以让< div& code> s链接和为不同的链接?



和这是正确的方式使用div内 a href

解决方案

不,分配给包含 a> 将被分配给它内部的每个元素。



这不是正确的方法。您可以使< a> 的行为类似于< div>



示例 [Demo]



CSS

  a.divlink {
display:block;
width:500px;
height:500px;
float:left;
}

HTML

 < div> 
< a class =divlinkhref =yourlink.html>
元素内的文本或元素
< / a>
< a class =divlinkhref =yourlink2.html>
另一个文本或元素
< / a>
< / div>


I want to make a div click-able and but inside this <div> i have another <div> which also should be click-able or linked.

HTML

<a href="#">
    <div class="box">
       <div class="plus"><img src="aaa.jpg"/></div>
    </div>
</a>

CSS

.box{
    float:left;
    width:100px;
    height:100px;
}
.plus{
    float:left;
    width:30px;
    height:30px;
}

Can i make both <div>s to link and for different links?

and Is this proper way use div inside a href ?

解决方案

No, the link assigned to the containing <a> will be assigned to every elements inside it.

And, this is not the proper way. You can make a <a> behave like a <div>.

An Example [Demo]

CSS

a.divlink { 
     display:block;
     width:500px;
     height:500px; 
     float:left;
}

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>

这篇关于&lt; DIV&gt;内部链接(&lt; a href =&quot;&gt;&gt;)标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆