php - 在某些 <td> 上显示 <div>

标签 php css html-table

我想展示某些 <div>在某个<td>一张 table 。这是我在 HTML 中尝试的内容:

<table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
        <td width="10%" valign="middle">{$avatar}{$change_avatar}</td>
        <td class="trow1" width="90%" valign="top">
            {$online_status}<span class="largetext"><strong>{$formattedname}</strong></span>
            <div class="smalltext">{$groupimage}</div>
        </td>
    </tr>
</table>

在这段代码中,我有这个:

$change_avatar = '<div class="change_avatar"><a href="usercp.php?action=avatar">Change Avatar</a></div>';

我要显示{$change_avatar}当鼠标移到第一个时鼠标悬停 <td>表的代码,我在上面显示的代码。

这是我使用的 CSS;

.change_avatar{
    display: none;
    font-size: 11px;
    background: #363737;
    color: #FFF;
    opacity: 0.8;
    border-radius: 2px;
    padding: 3px 5px;
}

.change_avatar a:link, .change_avatar a:visited, .change_avatar a:active{
    color: #FFF !important;
    text-decoration: none;
}

td:hover .change_avatar{
    display: inline;
    margin-top: 50px;
    margin-left: -70px;
    position: absolute;
}

请帮忙。

最佳答案

试试这个:

CSS:

.change_avatar{
    display: none;
    font-size: 11px;
    background: #363737;
    color: #FFF;
    opacity: 0.8;
    border-radius: 2px;
    padding: 3px 5px;
}

.change_avatar a:link, .change_avatar a:visited, .change_avatar a:active{
    color: #FFF !important;
    text-decoration: none;
}

td #change_avatar:hover .change_avatar{
    display: inline;
    margin-top: 50px;
    margin-left: -70px;
    position: absolute;
}

HTML:

<table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
        <td width="10%" valign="middle" id="change_avatar">{$avatar}{$change_avatar}</td>
        <td class="trow1" width="90%" valign="top">
            {$online_status}<span class="largetext"><strong>{$formattedname}</strong></span>
            <div class="smalltext">{$groupimage}</div>
        </td>
    </tr>
</table>

关于php - 在某些 <td> 上显示 <div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25663634/

相关文章:

jquery - Bootstrap 可折叠导航,屏幕宽度为 1280 像素

php - 日期时间 VS 时间戳性能

php - 如何使用MySQL和PHP每天增加一个值?

php - 在哪里可以获得 PHP 的所有多字节函数的完整列表?

html - 表格与 div 对齐

css - 如何从 ckeditor 内容和数据生成 pdf?

css - 如何在 table 隐藏部分的边缘正确转换阴影?

php - Ubuntu 13.10、PHP 5.5 上的 Phalcon 安装 - 无效操作码

javascript - 如何为鼠标事件处理程序实现额外的按键

html - 用图像填充 div 而不拉伸(stretch)