Bootstrap Media类,如何清除:左边的图像?

时间:2015-09-07 06:31:55

标签: html css twitter-bootstrap

请查看我的代码,我正在尝试让短信占据个人资料照片下方的空间,但似乎个人资料照片占据了整个空间而不让文字在其下方流动!我尝试使用clearfix,但我不认为我做得对!

.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文件并在本地运行它并且bootstrap cdn实际工作,它就无法正常工作。任何建议表示赞赏!请帮忙

2 个答案:

答案 0 :(得分:1)

块元素具有刚性边框,可将元素保持在一个框内。

由于media-body是一个块元素,它会将它们保持在一起,防止其中的文本覆盖在图像下方。

锚标记和段落应该在同一级别上,或者媒体体应该是内联元素。您可以通过添加以下样式来尝试。

.media-body {
    display: inline;
}

但是你可能不希望覆盖bootstrap的类样式。最好为元素创建一个新类,并覆盖该新元素的display属性。

答案 1 :(得分:0)

为什么你使用左拉类,在bootstrap中也提供了media-left。 你检查这个网址,这里也是解释。 enter link description here

你覆盖 .media-left a 这个css就是这样,你根据你的图像大小设置高度和宽度,不要忘记在css 显示中提及:内联块;