2017-12-15 8 views
0

私はCSSで新しく、HTMLページにステータスアイコンを追加しようとしています。これは、Webサーバからの連続AJAX呼び出しデータに基づいて更新されます。CSSを使用してステータスアイコンを追加

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ペイントソフトウェアを使用して作成したサンプルを試してみました、私は私のページに以下のようなものを表示したいです。

enter image description here

どのように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>

+0

を右下隅またはどのようにアイコンを移動する方法をあなたの質問ですあなたのAjaxレスポンスに基づいて異なるアイコンを表示しますか? – Wernerson

+0

右、それは...右下にアイコンを移動するには? – n33rma

答えて

2

.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>

0

何かが役立つかもしれない:私もHTMLを変更

注意を。私の知る限りは、あなたがこの意味undertoodとして

.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>

関連する問題