2016-03-30 2 views
0

私はthis fiddle画像の上に番号ラベルを追加

span.label{ 

     width:100px; color:#FFFFFF; 
     background-color:#F43B05; 
     float:right; padding:3px; 
     position:absolute; top:50px; left:5px; 
} 

を使用してspan.labelにこのCSSを追加しましたそして、私はこれ持って

EDIT:

enter image description here

ブートストラップを使ってイメージにラベルを付ける必要があります。

私はラベルの付いたこのイメージを持っている:

<span class="label label-success">4</span> 

<input class="img1" type="image" style="width:60px;height:60px" src="../images/molar_left_t.png" id="oone" name="one" alt="button"/> 

<div title="3rd Molar - Upper Rigth Jaw" id="div_one" class="collapse"><?php echo $resTeeth['one'] ?> 

</div> 

しかし、これは私が欲しいものではありません。

enter image description here

そして、ここではそのためのコードです。私が欲しいのは、画像の上にこの番号4の緑色のラベルを付け加え、その横には付けないことです。

私はこの試みた:

<span class="label label-danger">4 
<input class="img1" type="image" style="width:60px;height:60px" src="../images/molar_left_t.png" id="oone" name="one" alt="button"/> 
<div title="3rd Molar - Upper Rigth Jaw" id="div_one" class="collapse"><?php echo $resTeeth['one'] ?> 
</div> 
</span> 

をそして、私はこの持っている:ちょうどspan.labelためfloat:leftを使用して、label要素の位置を設定するためにマージンを設定し

enter image description here

+0

私はあなたが私はあなたが相対的な位置のdiv内のスパンを配置し、絶対的なスパンを配置することができ – androidnation

+0

をしようとしたかを見ることができ、私の質問を編集しました。また、あなたはコンテンツとして数字「4」を使用して:を使用して、cssでそれを行うこともできます。 – Goombah

+0

さて、私の質問の一番上にある私の編集を参照してください – androidnation

答えて

1

これはあなたの答えになると確信しています。 おかげ

/* CSS used here will be applied after bootstrap.css */ 
 
.badge-notify{ 
 
    background-color:red !important; 
 
    position:relative; 
 
    top: -20px; 
 
    left: -35px; 
 
    }
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> 
 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 

 
<div class="container"> 
 
    <button class="btn btn-default btn-lg btn-link" style="font-size:36px;"> 
 
    <span class="glyphicon glyphicon-comment"></span> 
 
    </button> 
 
    <span class="badge badge-notify">3</span> 
 
</div>

1

を。

+0

そして私はそれをどうしていますか? – androidnation

+0

CSS: span.label { display:block; float:left; margin-bottom://ここにピクセル値を入力します margin-left://ここにピクセル値を入力してください } – pzworks

+0

これは私の質問の先頭にある私の編集を参照してください – androidnation

1

はこれを試してみてください。

<div class="container"> 
    <img src="" /> 
    <span class="lbl">something</span> 
</div> 

.container{ 
position:relative; 
} 
.container img, .container .lbl{ 
position:absolute; 
top:0px; 
left:0px; 
} 
1

私はコメントで提案したもののように、ここでは2つの例を作りました。

JSFiddle

div 
{ 
    position: relative; 
    width: 300px; 
    height: 300px; 
} 

span 
{ 
    position: absolute; 
background: red; 
    color: white; 
    height: 60px; 
    width: 60px; 
    text-align: center; 
    font-family: Tahoma, sans-serif; 
    font-size: 40px; 
    line-height: 55px; 
    border-radius: 10px; 
    bottom: 0; 
    right: 0; 
} 

.icon 
{ 
    position: relative; 
} 

.icon:after 
{ 
    content:"4"; 
    position: absolute; 
    display: block; 
    background: red; 
    color: white; 
    height: 60px; 
    width: 60px; 
    text-align: center; 
    font-family: Tahoma, sans-serif; 
    font-size: 40px; 
    line-height: 55px; 
    border-radius: 10px; 
    bottom: 0; 
    right: 0; 
} 
+0

これは私にとってもうまくいきます – androidnation

関連する問題