html - 标题自定义
问题描述
有没有办法自定义标题?我希望它有一个红色的背景,但我没有看到任何方法来做到这一点。如果有一种简单的方法可以做到这一点,那就太好了!
.box {
background-color: red;
height: 50px;
width: 50px;
text-align: center;
}
<div title="Hi!" class="box">Hi!</div>
解决方案
您可以添加伪元素并在悬停时显示它。
例子
.box {
background-color: red;
height: 50px;
width: 50px;
text-align: center;
position: relative;
}
.box:before {
content: "Hi!";
display: none;
position: absolute;
right: -30px;
width: 50px;
height: 20px;
background: blue;
}
.box:hover:before {
display: block;
}
<div class="box">Hi!</div>
推荐阅读
- mongodb - 为集群创建的用户的 Mongo DB Atlas 密码更改
- unity3d - GetKeyDown 或 GetKey 不起作用,而是发送错误消息。(统一)
- cucumber - 如何在黄瓜中执行一个文件具有一些功能列表
- keras - 在 tensorflow / Keras 中如何实现 val_loss 和 val_accuracy?
- android - Android Exo Player,在视频顶部的特定位置添加一个视图
- json - 推送到 Heroku 时,纱线安装一直在循环
- ios - App Store应用需要用苹果最新的代码签名证书重新签名
- android - 我可以通过“使用 Apple ID 登录”获取用户的电话号码以进行电话验证吗?
- swift - 无法访问 MTKView
- sql - 如何让我的 PostgresSQL 成功执行调用?