Search code examples
javascripthtmltwitter-bootstrappanel

Bootstrap panel inside a column class going beyond that class


I'm trying to create a panel inside a col-sm-6 column.

is there a way to get the panel heading and panel content not going out of the 1st column ?

here is my code so far:

<!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>

I've tried to add this CSS but its not working

.container{
    position: absolute;
}

enter image description here

plnkr link


Solution

  • Use this code for the body:

    <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>