2015-09-07 14 views
0

請查看我的代碼,我試圖讓文字信息佔據配置文件照片下方的空間,但似乎配置文件照片佔用了整個空間,並且不讓文本在其下面流動!我嘗試使用clearfix,但我不認爲我做對了!Bootstrap媒體類,如何清除:在圖像上留下?

.rounded{ 
 
    border-radius:100%; 
 
    width:50px; 
 
    height:50px; 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <meta charset="UTF-8"> 
 
    <title>Admin Feature</title> 
 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> 
 
    <link rel="stylesheet" href="news.css"> 
 
</head> 
 
<body> 
 

 
<div class="question-news text-center"> 
 
<button class="btn btn-default admin-news-question-btn" data-toggle="modal" data-target="#newsModal"><b>Admin Announcements</b> <i class="fa fa-question"></i></button> 
 
</div> 
 

 
<div class="row news-box"> 
 
    <div class="container-fluid"> 
 
    <div class="admin-news"> 
 
     <div class="media"> 
 
     <a href="#" class="pull-left"> 
 
      <img src="https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfa1/v/t1.0-9/184091_469721973060655_360032267_n.jpg?oh=755e7a595507586b075f7c2f4de03eb4&oe=566A8D32&__gda__=1449807500_fd2aec75a083c6907e4827ea6c817139" alt="" class="media-object rounded"> 
 
     </a> 
 
     <div class="media-body"> 
 
      <h4 class="media-heading"> 
 
      Administrator <i class="fa fa-lock"></i> 
 
      </h4> 
 
      <p class="news-font"><i class="fa fa-envelope-o"></i> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum </p> 
 
      <i class="fa fa-clock-o"></i> <small><i>Posted on Monday 6pm</i></small> 
 
      &nbsp 
 
      <i class="fa fa-thumbs-o-up like-btn"></i> 4 
 
      &nbsp 
 
      <i class="fa fa-thumbs-o-down dislike-btn"></i> 5 
 
     </div> 
 
     </div> 
 
    </div> 
 

 
    </div> 
 
</div> 
 

 
<div class="row news-box"> 
 
    <div class="container-fluid"> 
 
    <div class="admin-news"> 
 
     <div class="media"> 
 
     <a href="#" class="pull-left"> 
 
      <img src="https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfa1/v/t1.0-9/184091_469721973060655_360032267_n.jpg?oh=755e7a595507586b075f7c2f4de03eb4&oe=566A8D32&__gda__=1449807500_fd2aec75a083c6907e4827ea6c817139" alt="" class="media-object rounded"> 
 
     </a> 
 
     <div class="media-body"> 
 
      <h4 class="media-heading"> 
 
      Administrator <i class="fa fa-lock"></i> 
 
      </h4> 
 
      <p class="news-font"><i class="fa fa-envelope-o"></i> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum </p> 
 
      <i class="fa fa-clock-o"></i> <small><i>Posted on Monday 6pm</i></small> 
 
      &nbsp 
 
      <i class="fa fa-thumbs-o-up like-btn"></i> 4 
 
      &nbsp 
 
      <i class="fa fa-thumbs-o-down dislike-btn"></i> 5 
 
     </div> 
 
     </div> 
 
    </div> 
 

 
    </div> 
 
</div> 
 

 

 

 
<!-- Modal --> 
 
<div id="newsModal" class="modal fade news-modal" role="dialog"> 
 
    <div class="modal-dialog color-modal"> 
 

 
    <!-- Modal content--> 
 
    <div class="modal-content"> 
 
     <div class="modal-header"> 
 
     <button type="button" class="close" data-dismiss="modal">&times;</button> 
 
     <h4 class="modal-title">Admin Announcements <i class="fa fa-newspaper-o"></i></h4> 
 
     </div> 
 
     <div class="modal-body"> 
 
     <p>This section is open for users to read the latest annoucements created by the Admin. 
 
     Feel free to "like" or "dislike" the Admin's accouncement.</p> 
 
     </div> 
 
     <div class="modal-footer"> 
 
     <button type="button" class="btn admin-news-question-btn" data-dismiss="modal">Close</button> 
 
     </div> 
 
    </div> 
 

 
    </div> 
 
</div> 
 

 

 
<!-- jQuery library --> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
 

 
<!-- Latest compiled JavaScript --> 
 
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> 
 
</body> 
 
</html>

運行在這裏摘錄作品古怪,但如果你複製並粘貼HTML文件以及引導CDN實際工作在本地運行它,它不工作。任何建議表示讚賞!請幫助

回答

1

塊元素具有嚴格的邊界,它們將元素保持在一個盒子內。

由於media-body是一個塊元素,它將它們保持在一起,防止其內部的文本覆蓋圖像下方。

定位標記和段落應該位於同一層,否則媒體正文應該是內聯元素。您可以通過添加以下樣式來嘗試。

.media-body { 
    display: inline; 
} 

但是,您可能不希望覆蓋引導程序的類樣式。如果你爲你的元素創建一個新的類並覆蓋該新元素的顯示屬性會更好。

+0

你是對的,它的工作原理。爲你工作的小提琴。 https://jsfiddle.net/DTcHh/11833/ –

+0

很高興它的工作。不要忘記接受你的問題的答案。 – Azadrum

0

爲什麼你在使用左拉類,在bootstrap中也提供了媒體左鍵。 你檢查這個URL,這裏也是解釋。 enter link description here

並且覆蓋了.media,離開這裏這個CSS是,你把這個根據你的圖像大小的高度和寬度,不要忘記在CSS提顯示:inline-block的;

相關問題