javascript - table单元格里这种提示效果用什么实现的
巴扎黑
巴扎黑 2017-04-11 10:01:52
[JavaScript讨论组]

想问下table单元格内这种如图这种效果是怎么实现的,(这种是类似悬浮的效果还是水印的效果)

巴扎黑
巴扎黑

全部回复(2)
巴扎黑

简单写了一点:
html:

<table border=1>
    <tr>
        <td>hello</td>
        <td class="tip warn">
              正常
            <span class="undiscuss">待处理</span>
        </td>
    </tr>
    <tr>
        <td>world</td>
        <td class="tip normal">
            异常
            <span class="discuss">已处理</span>
        </td>
    </tr>
</table>

css:

td{padding: 20px 60px}
.tip{position:relative}
.warn{color: red;}
.normal{color: green}
.undiscuss{position: absolute;right:0;top:0;padding:3px 5px;border:1px solid green;color:green
}
.discuss{position: absolute;right:0;top:0;padding:3px 5px;border:1px solid orange;color:orange
}

效果:

怪我咯

用:after伪类实现

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<table border=1>
    <tr>
        <td class="undiscuss">
            正常
        </td>
    </tr>
    <tr>
        <td class="discuss">
            异常
        </td>
    </tr>
</table>
<style type="text/css">
td{padding: 20px 60px; position: relative;}
td.undiscuss:after,td.discuss:after{
    position: absolute;right:0;top:0;padding:3px 5px;
}
td.undiscuss:after{
    border:1px solid green;color:green;content: "待处理";
}
td.discuss:after{
    border:1px solid orange;color:orange;content: "已处理";
}
</style>
</body>
</html>
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号