非法的替代品 <br>或 <p><li>内标签悬停? [英] Alternatives to illegal <br> or <p> within <li> tags on a hover?

查看:23
本文介绍了非法的替代品 <br>或 <p><li>内标签悬停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人建议在包含悬停弹出伪类的 <li> 标记中创建段落类型的行空间?

Does anyone have a suggestion for creating paragraph-type line spaces within a <li> tag that includes a hovered pop-up pseudo-class?

我有一个 <span>a:hover 上弹出,我希望将弹出的文本分成 2 个段落.它适用于 FF 中的 <br> 但我想做正确的事情(现在我发现它错了!)...

I have a <span> that pops up on a:hover and I want the text that pops up to be broken into 2 paragraphs. It works with <br> in FF but I want to do the right thing (now that I've discovered it's wrong!)...

html:

<div id="rightlist">
  <ul>
      <li><a href="">List item
          <span>
             words words words that are "paragraph" 1 of List item
             <br><br>
             different words that make up "paragraph" 2 of List item
          </span></a></li>

css:

#rightlist {
margin-top: 10px; margin-right: 5px; width: 387px ; height: 239px ;
background-color: #7EBB11 ;
display: table-cell; 
z-index: 100 ;
    float: right ;
}

#rightlist ul {
  text-align: left;
margin: 0;
   margin-top: 6px;
font-family: sans-serif;
font-size: 20px ;
color: black ;
}

#rightlist a 
{
    display: table-cell;
text-decoration: none; color: black; 
background: #7EBB11 ; 
}

/*appearance of the <a> item (but before the <span> tag) on hover*/
#rightlist a:hover {
color: white;
}

/*appearance of the spanned content within <a></a> tags when not hovered */
/* %%%%% important - keep position:absolute in this div %%%%% */
#rightlist a span {
display: none;
position: absolute ;
margin-left: -412px;
top: -10px; left: 10px; padding: 10px ;
z-index: 100;
width: 380px; height: 222px; 
color: white;  background-color: #7EBB11;
font: 0.75em Verdana, sans-serif; font-size: 13px ; color: black;
text-align: left;
}



/*appearance of spanned content within <a> tags when hovered*/
#rightlist a:hover span {
display: table-cell ;
}

推荐答案

您的问题可能源于您使用的是 <span>标签错误.

Your problem may arise from the fact that you're using a <span> tag incorrectly.

Span 应该是内联元素,并且您将其设置为好像它是块元素一样.诚然,您可以通过添加正确的样式来强制 span 充当块元素,但这可能并不总是被各种浏览器所尊重.

Spans are supposed to be inline elements and you're styling it as though it were a block element. Admittedly you can force a span to behave as a block element by adding the right style, but this may not always be honoured by the various browsers out there.

理想情况下,您应该改用 div.然后,您可以使用 p 标签或进一步的 div 标签来指示段落(理想情况下是 p,因为从语义上讲它们实际上是段落而不是不相关的文本块).

Ideally you should be using a div instead. You can then use either p tags or further div tags to indicate the paragraphs (ideally p, since semantically they actually are paragraphs rather than unrelated blocks of text).

这篇关于非法的替代品 &lt;br&gt;或 &lt;p&gt;&lt;li&gt;内标签悬停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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