列类中的Bootstrap面板超出了该类

时间:2017-08-11 02:11:58

标签: javascript html5 twitter-bootstrap panel

我正在尝试在col-sm-6列中创建一个面板。

有没有办法让面板标题和面板内容不会超出第一列?

到目前为止,这是我的代码:

<!DOCTYPE html>
<html lang="en">
   <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class="container-fluid">
         <div class="row">
            <div class="col-sm-6" style="background-color:lavender;">
               .col-sm-6
               <div class="container">
                  <h3>Panel Heading</h3>
                  <div class="panel panel-default">
                     <div class="panel-heading">Panel Heading
                     </div>
                     <div class="panel-body">Panel Content
                     </div>
                  </div>
               </div>
            </div>
            <div class="col-sm-6" style="background-color:lavenderblush;">.col-sm-6</div>
            </div>
      </div>
   </body>
</html>

我试图添加这个CSS,但它无法正常工作

.container{
    position: absolute;
}

enter image description here

plnkr link

1 个答案:

答案 0 :(得分:2)

将此代码用于正文:

&#13;
&#13;
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6" style="background-color:lavender;">
      .col-sm-6
      <div class="row">
        <h3>Panel Heading</h3>
        <div class="panel panel-default">
          <div class="panel-heading">Panel Heading
          </div>
          <div class="panel-body">Panel Content
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-6" style="background-color:lavenderblush;">.col-sm-6</div>
  </div>
</div>
&#13;
&#13;
&#13;