div 内锚 [英] div inside anchor

查看:19
本文介绍了div 内锚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不会一直发生.不能重现的错误不是错误!

This doesn't happen all the time. A bug is not a bug if cannot be reproduced!

首先,我认为这是我年轻的编程技能的错误,但在我的两个站点中出现了同样的错误,显然是在相同的情况下.

First, I thought this was a mistake of my young programming skills but same error appears in my two sites, apparently under the same circumstances.

<a style="display:block;" href="link">
 <div>text1</div>
 <div>text2</div>
</a>

有时,在浏览时,其中包含 div 的链接呈现奇怪的呈现方式,页面上无缘无故地出现重复元素,文本在不同链接之间分布,真是一团糟.

Sometimes, while browsing, links with divs inside them render strangely, duplicate elements appear on the page with no reason, text gets distributed between different links, a real mess.

真实截图:

http://cupacupelor.ro/img/help.jpg
http://www.carbroker.ro/img/help.jpg

有人遇到过这个问题吗?有解决办法吗?我对涉及 JavaScript 的修复不感兴趣!

Anyone faced this problem? Is there a solution? I'm not interested of fixes involving JavaScript!

推荐答案

我猜你链接中的 div 会导致某些浏览器不一致(可能是你的 css 在这里播放).

I guess your divs in links cause inconsistency in some browsers (may be your css playing here).

语义",有效标记是一些流行词.

"Semantics", valid markup are some buzz words.

那么为什么要在 <A> 标签中使用 DIV.你可以试试这样的

So why would you want DIVs in an <A> tag. You can try someting like this

<a href="#">
       <span class="divstyle">Text 1</span>
       <span class="divstyle">Text 2</span>
</a>

然后在 CSS 中

.divstyle { 
    display: block; //and other styles etc
 }

这篇关于div 内锚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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