Php 文本显示在图像悬停上 /*跨度的CSS*/ .悬停{ 可见性:隐藏; 宽度:120px; 背景色:黑色; 颜色:#fff; 文本对齐:居中; 边界半径:6px; 填充:5px0; 位置:绝对位置; z指数:1; 底部:100%; 左:96%; 左边距:-60px; } /*包含跨距的文本的CSS*/ .图像测试{ 位置:相对位置; } /*悬停文本的CSS*/ .imagetest:悬停。悬停{ 能见度:可见; 显示:内联块; }

Php 文本显示在图像悬停上 /*跨度的CSS*/ .悬停{ 可见性:隐藏; 宽度:120px; 背景色:黑色; 颜色:#fff; 文本对齐:居中; 边界半径:6px; 填充:5px0; 位置:绝对位置; z指数:1; 底部:100%; 左:96%; 左边距:-60px; } /*包含跨距的文本的CSS*/ .图像测试{ 位置:相对位置; } /*悬停文本的CSS*/ .imagetest:悬停。悬停{ 能见度:可见; 显示:内联块; },php,html,css,Php,Html,Css,PHP/HTML <style> /* CSS for the span */ .hover { visibility: hidden; width: 120px; background-color: black; color: #fff; text-align: center; border-radius: 6px; padding: 5px 0;

PHP/HTML

<style>
    /* CSS for the span */
    .hover {
        visibility: hidden;
        width: 120px;
        background-color: black;
        color: #fff;
        text-align: center;
        border-radius: 6px;
        padding: 5px 0;
        position: absolute;
        z-index: 1;
        bottom: 100%;
        left: 96%;
        margin-left: -60px;
    }

    /* CSS for the text containing the span */
    .imagetest {
        position: relative;
    }

    /* CSS for text on hover */
    .imagetest:hover .hover {
        visibility: visible;
        display:inline-block;                
    }
</style>

您的CSS正在尝试选择“.imagetest”的子元素,该元素的类为“hover”。由于span.hover标记不是.imagetest的子项,css不会选择它

试试这样的

<?php
    echo "<div class='hoverText' align=right><img class='imagetest' src='Files/infoplaceholder.png' height=20 width=20><span class='hover'> See About Page for more info </span></div>";
    echo "<BR>";
?>

    <div class='hoverText' align=right>
        <span class='imagetest'>
            <img src='Files/infoplaceholder.png' height=20 width=20 />
            <span class='hover' > See About Page for more info </span>
        </span>
    </div>
.imagetest:hover + .hover {
    visibility: visible;
    display: inline-block;
}