【问题标题】:Div hover on icon with SASS [duplicate]div悬停在带有SASS的图标上[重复]
【发布时间】:2013-03-28 06:43:23
【问题描述】:

当您将鼠标悬停在图标文本上时,我在如何显示 div 方面犯了一些错误。

问题是当您将鼠标悬停在标题的整行上时,我的 div 就会出现。我在 sass 或页面结构中的问题在哪里,或者两者兼而有之? 我希望我的 div 在鼠标悬停时出现在图标信息中

您也可以在此处查看示例:http://codepen.io/anon/pen/gduJF

这是我的 HTML:

<div id="spinCastJs">
    <div id="spintitle">
      <h1>Example<span id="spininfo">i</span></h1>
      <div id="instructions">
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text</p>
      </div>
    </div>
</div>

和样式

#spinCastJs
  #spintitle
    background: #ddd
    padding: 6px

    h1
    text-align: center
    color: #04677e
    font-weight: bold
    font-size: 1.2em

    #instructions
      display: none
      position: absolute
      background: #ffffff
      right: 0px
      height: 100px

    #spininfo
      float: right
      font-style: normal
      font-size: 1.1em
      background: #ddd
      height: 50px
      width: 18px
      color: #ffffff
      border-radius: 3px
      background: #bf24bf
    &:hover
      #instructions
        display: block
        border: 1px solid #ddd

【问题讨论】:

  • Sass 与此无关,这是一个 CSS 限制。您的 span 必须是您希望隐藏的 div 的兄弟姐妹或祖先。

标签: css hover sass


【解决方案1】:

您需要在#spaninfo span 内显示元素

例如:我在下面的代码中放入了一个 id 为 test 的 div,其中 span 仅用于示例。

HTML

 <h1>Example<span id="spininfo">i<div id="test">test</div></span></h1>

萨斯

 #spintitle
   #spininfo
     float: right
     font-style: normal
     font-size: 1.1em
     background: #ddd
     height: 50px
     width: 18px
     color: #ffffff
     border-radius: 3px
     background: #bf24bf
     display: block
     &:hover
       #test
         display: block
         border: 1px solid #ddd
         color: red

【讨论】:

  • 您的标记无效。 Span 不能包含 div。
  • 是的,我同意你的看法,这不是一个好习惯。由于 OP 有跨度,我给跨度一个 display: block 并试图解释。
  • 是的,但没有成功,我想也许我需要做一个工具提示,只是大声思考。
猜你喜欢
  • 1970-01-01
  • 2018-11-07
  • 2014-04-23
  • 1970-01-01
  • 2011-02-28
  • 2020-11-23
  • 1970-01-01
  • 1970-01-01
  • 2013-02-18
相关资源
最近更新 更多