【问题标题】:Hover :before set content in two lines? [duplicate]悬停:在两行设置内容之前? [复制]
【发布时间】:2016-04-28 13:28:51
【问题描述】:

有简单的悬停类:

.logos:hover:before {
  content: "For more details click here";
  position: absolute;
  color: #fff;
  font-size: 18px;
  bottom:10%;
  left:5%;
background: #000;
}
<div class="logos"> Text </div>

这很好,在悬停元素上,我看到了文字。现在,是否有可能像这样将文本放入行中:

更多详情

点击这里

Tnx, P

【问题讨论】:

    标签: css hover


    【解决方案1】:

    您可以在after 伪中放置click here,并为两者提供固定的底部位置

    .logos:hover:before {
      content: "For more details";
      position: absolute;
      color: #fff;
      font-size: 18px;
      bottom:40px;
      left:5%;
    background: #000;
    }
    
    .logos:hover:after {
      content: "click here";
      position: absolute;
      color: #fff;
      font-size: 18px;
      bottom:10px;
      left:5%;
    background: #000;
    }
    <div class="logos"> Text </div>

    【讨论】:

    • 解决问题! Tnx!
    • 不客气,乐于助人。
    【解决方案2】:

    将 :before 设置为固定的,添加

    .logos:hover:before { 
    width: 100px /* please insert the width you need for your problem*/ 
    [ ... here are your other CSS-rules ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-26
      • 2021-07-31
      • 2016-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多