weixin_33724046 2017-12-15 14:05 采纳率: 0%
浏览 123

使用CSS添加状态图标

I'm new in CSS and I'm trying to add status icon on my HTML page which will gets updated based on continuous AJAX call data from web server.

AJAX response will be JSON object:

// 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'
}

I tried to created sample using MS Paint software, I want to display something like below on my page.

enter image description here

How do I place circle on database icon using 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>&nbsp; Down 
  </div>

</body>
</html>

</div>
  • 写回答

2条回答 默认 最新

  • weixin_33698043 2017-12-15 14:25
    关注

    Something like this might help:

    Note that I changed the HTML as well.

    .db-status .fa{
      font-size: 1.5em;
    }
    
    .db-status-icon{
      padding-left: 10px;
      padding-top: 10px;
      font-size: 1em !important;
    }
    <!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>
        <span class="db-status fa-stack">
          <i class="fa fa-database fa-stack-2x" aria-hidden="true"></i>
          <i class="db-status-icon fa fa-circle text-danger fa-stack-2x" aria-hidden="true"></i>
        </span>&nbsp; Down 
      </div>
    
    </body>
    </html>

    </div>
    
    评论

报告相同问题?