请查看我的代码,我正在尝试让短信占用个人资料照片下方的空间,但个人资料照片似乎占用了全部空间,并且不允许文字在其下方流动!我尝试使用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实际运行的情况下在本地运行该文件,则该代码将无法正常工作。任何建议表示赞赏!请帮忙

最佳答案

块元素具有刚性边界,可将内部的元素保持在一个盒子中。

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

锚标记和段落应处于同一级别,或者media-body应该是内联元素。您可以通过添加以下样式来尝试一下。

.media-body {
    display: inline;
}


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

09-30 14:53
查看更多