css - 纯 CSS 悬停框移动页面文本

标签 css popup hover

严格使用 CSS,我正在尝试制作一个描述框。到目前为止,一切都很好,看起来很棒。但是有一个问题。将鼠标悬停在上方时,它会四处移动页面的其余部分,以便为最初放置框腾出空间。将鼠标悬停在触发文本上时,如何让页面上的所有文本保持静态? 此外,我使用的是 Drupal、Danland 主题,但我认为在特定情况下这不会产生任何影响。

    <style>
    span{
    background:#F8F8F8;
    border: 5px solid #DFDFDF;
    color: #717171;
    font-size: 13px;
    letter-spacing: 1px;
    line-height: 30px;
    position: relative;
    text-align: center;
    text-transform: uppercase;
    top: -200px;
    left:-30px;
    display:none;
    }
        span:after{
    content:'';
    position:absolute;
    bottom:-10px;
    width:10px;
    height:10px;
    border-right:5px solid #dfdfdf;
    border-bottom:5px solid #dfdfdf;
    background:#f8f8f8;
    left:31%;
    margin-left:-10px;
    -moz-transform:rotate(45deg);
    -webkit-transform:rotate(45deg);
    transform:rotate(45deg);
    display:inline;
    }
        p{
    margin:10px;
    float:left;
    position:relative;
    cursor:pointer;
    overflow:visible;
    }

        p:hover span{
    display:block;
    }</style>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>Angkor Wat<span><img width="300" src="http://www.lotusangkortravel.com/themes/danland/images/slideshows/angkor-wat.JPG"><br>
Angkor Wat central complex</span></p>
<br><br><br>
<b>This text should not move on hover.</b>

最佳答案

问题是垃圾邮件的position:relative。我将位置更改为绝对位置并且有效。

position: absolute;

关于css - 纯 CSS 悬停框移动页面文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18710590/

相关文章:

javascript - 菜单在鼠标悬停时淡入淡出

html - 在 Google Chrome for Mac 上将 CSS 中的输入按钮居中

css - 修复错误后的 Bootstrap 4 beta 服务器端验证

javascript - 使用 Leaflet.js 关闭所有弹出窗口

jquery - 使用伪元素 :before and :after? 悬停时动画 Logo

CSS将鼠标悬停在wordpress中的缩略图上

javascript - 在 angularJS 中使用 html ID

jquery - 带有大量复选框的弹出窗口的渲染速度非常慢

wpf - 弹出控件 WPF 的外部鼠标单击

javascript - 使用变量将 jQuery 处理程序分配给多个 DIV