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

问题描述

这不会一直发生。首先,我认为这是我年轻的编程技巧的错误,但同样的错误出现在我的两个网站中,显然是在同样的情况。

 < a style =display:block; HREF = 链接 > 
< div> text1< / div>
< div> text2< / div>
< / a>

有时,在浏览时,与 div 其中的内容呈现奇怪,重复的元素出现在页面上没有任何理由,文本分布在不同的链接之间,真正的混乱。



真实截图:



'p>



任何人都遇到过这个问题?有解决方案吗?我对JavaScript的修复不感兴趣!

解决方案

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



语义,有效的标记是一些流行词。

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

 < a href =#> 
< span class =divstyle>文字1< / span>
< span class =divstyle>文字2< / span>
< / a>

然后在CSS中

  .divstyle {
display:block; //和其他样式等
}


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>

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.

Real screenshots:

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

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

解决方案

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

"Semantics", valid markup are some buzz words.

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>

then in CSS

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

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

10-16 02:30