2016-05-13 19 views
0

は省略記号ブートストラップ省略記号は、ここで

<div class="list-group" id="NotificationList"> 
    <a href="#" class="list-group-item"> 
    <div class="checkbox"> 
     <label> 
     <input type="checkbox"> 
     </label> 
    </div> 
    <span class="">This is your first notification.</span> 
    <span class="badge">12:10 AM</span> 
    </a> 

    <a href="#" class="list-group-item"> 
    <div class="checkbox"> 
     <label> 
     <input type="checkbox"> 
     </label> 
    </div> 
    <span class="notificat" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">This is your first notification. This is your first notification. This is your first notification. This is your first notification. 
          </span> 
    <span class="badge">12:10 AM</span> 
    </a> 
    <a href="#" class="list-group-item"> 
    <div class="checkbox"> 
     <label> 
     <input type="checkbox"> 
     </label> 
    </div> 
    <span class="notificat" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">This is your first notification.</span> 
    <span class="badge">12:10 AM</span> 
    </a> 
</div> 

CSSと私のコードで上書きされた行になるさ私の期待どおりに働いています。

<div class="list-group" id="NotificationList"> 
    <a href="#" class="list-group-item"> 
    <div class="checkbox"> 
     <label> 
     <input type="checkbox"> 
     </label> 
    </div> 
    <span class="">This is your first notification.</span> 
    <span class="badge">12:10 AM</span> 
    </a> 
    <a href="#" class="list-group-item"> 
    <div class="checkbox"> 
     <label> 
     <input type="checkbox"> 
     </label> 
    </div> 
    <span class="">This is your first notification.</span> 
    <span class="badge">12:10 AM</span> 
    </a> 
    <a href="#" class="list-group-item"> 
    <div class="checkbox"> 
     <label> 
     <input type="checkbox"> 
     </label> 
    </div> 
    <span class="">This is your first notification.</span> 
    <span class="badge">12:10 AM</span> 
    </a> 
    <a href="#" class="list-group-item"> 
    <div class="checkbox"> 
     <label> 
     <input type="checkbox"> 
     </label> 
    </div> 
    <span class="">This is your first notification.</span> 
    <span class="badge">12:10 AM</span> 
    </a> 
</div> 

CSS:

.checkbox { 
    float: left; 
} 

フィドル:https://jsfiddle.net/SimplytheVinay/mp97gLjm/

答えて

2

notificatクラスの表示をinline-blockに変更してみてください。左に浮かべる必要はありません。

.notificat { 
    max-width: 300px; 
    display: inline-block; 
} 

.checkbox { 
 
    float: left; 
 
} 
 

 
.notificat { 
 
    max-width: 300px; 
 
    display: inline-block; 
 
} 
 

 
.list-group-item{ 
 
    padding: 9px 15px !important; /* adjust padding from 10px to 9px to keep same list view after adding Ellipsis */ 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> 
 
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 
<div class="list-group" id="NotificationList"> 
 
    <a data-toggle="modal" data-target="#notificationModal" class="list-group-item"> 
 
     <div class="checkbox"> 
 
      <label> 
 
      <input type="checkbox"> 
 
      </label> 
 
     </div> 
 
     <span class="">This is your first notification.</span> 
 
     <span class="badge">12:10 AM</span> 
 
    </a> 
 
    <a data-toggle="popover" data-placement="top" data-content="This is your first notification." class="list-group-item"> 
 
     <div class="checkbox"> 
 
      <label> 
 
      <input type="checkbox"> 
 
      </label> 
 
     </div> 
 
     <span class="notificat" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">This is your first notification. This is your first notification. This is your first notification. This is your first notification. 
 
     </span> 
 
     <span class="badge">12:10 AM</span> 
 
    </a> 
 
    <a href="#" class="list-group-item"> 
 
     <div class="checkbox"> 
 
      <label> 
 
      <input type="checkbox"> 
 
      </label> 
 
     </div> 
 
     <span class="notificat" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">This is your first notification.</span> 
 
     <span class="badge">12:10 AM</span> 
 
    </a> 
 
</div>

+0

ありがとう:)表示を追加する:インラインブロック;問題を解決します。もう一つ、パディングを変更する理由は何ですか?省略記号は要素の周囲のパディングを変更しますか? – Crawling

+0

@クロールあなたをお待ちしております。パディングの変更はオプションですが、_display:inline-block; _ビューの変更を引き起こします。気にしないで!パディング値を変更して、ビューがどのように変更されるかを見ることができます。 –

2

あなただけ削除することができます "フロート:左;" このクラス ".notificat" を

これを削除します。

.notificat { 
    float: left; 
} 

参照Updated Fiddle Demo

+0

はい、それは上書き問題を解決します。しかし、省略記号はこれで動作しません。表示を追加する:インラインブロック;問題を解決します。 – Crawling

関連する問題