我是 CSS 的新手,我正在尝试在我的 HTML 页面上添加状态图标,该图标将根据来自网络服务器的连续 AJAX 调用数据进行更新。
AJAX 响应将是 JSON 对象:
// In case of Success
{
status: 0,
message: 'Success'
}
// In case of Error
{
status: 1,
message: 'Error'
}
// In case of Server is Busy
{
status: 2,
message: 'Busy'
}
我尝试使用 MS Paint 软件创建示例,我想在我的页面上显示如下内容。
如何使用 CSS 在数据库图标上放置圆圈?
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div>
<i class="fa fa-database" aria-hidden="true"></i>
<i class="fa fa-circle text-danger" aria-hidden="true"></i> Down
</div>
</body>
</html>
最佳答案
据我了解你的意思是:
.database {
position: relative;
display: inline-block;
margin: 10px;
}
.database .fa-database {
font-size: 30px;
}
.database .fa-circle {
position: absolute;
bottom: 0;
right: 0;
margin: -3px -6px;
}
.status {
display: inline-block;
}
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="database">
<i class="fa fa-database" aria-hidden="true"></i>
<i class="fa fa-circle text-danger" aria-hidden="true"></i>
</div>
<p class="status">Down</p>
</body>
</html>
关于html - 使用 CSS 添加状态图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47833995/