user2924127
user2924127

Reputation: 6240

Two divs left and right. Left is shorter so white space below. Fill it with an image.

Bootstrap: I have a list on the left side that is shorter than the table on its right. As a result it looks awkward and I would like to put an image below the list on the left side to fill the white space on the left below the list. I would like this image to be center vertically and horizontally and scale as best as possible. The problem right now is the image doesn't center and it won't center.

<div class="row-fluid">
   <div class="col-md-5">
      <p>List</p>
      <span class="list-group-item list-group-item-success">Item1</span>
      <span class="list-group-item">Item2</span>
      <span class="list-group-item list-group-item-success">Item3</span>
      <span class="list-group-item">Item4</span>
      <span class="list-group-item list-group-item-success">Item5</span>
      <span class="list-group-item">Item6</span>
      <span class="list-group-item list-group-item-success">Item7</span>

   <img class="img-circle" src="img/image.jpg">

   </div>
   <div class="col-md-6">
      <p>Table</p>
      <table class="table table-striped table-bordered table-hover">
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
      </table>
   </div>
</div>

Upvotes: 0

Views: 71

Answers (2)

Alexei Zababurin
Alexei Zababurin

Reputation: 957

@charset "utf-8";
html {
	background: #ccc;
	min-height: 100%;
	font-family: sans-serif;
	font-size: 5px;
	display: -webkit-flex;
	display: flex;
	flex-direction: column;
}
body {
	margin: 0;
	padding: 15px;
	display: -webkit-flex;
	display: flex;
	flex-direction: column;
	flex: auto;
}

.box {
	width: 100%;
	/*max-width: 960px;*/
	margin: 0 auto;
	display: -webkit-flex;
	display: flex;
	flex-wrap: wrap;
}
.box-base {
	background: #222;
	min-height: 430px;
	font-size: 5rem;
	color: #eee;
	flex: auto;

	display: -webkit-flex;
	display: flex;
	justify-content: center;
	align-items: center;
}
.box-side {
	margin-right: 30px;
	display: -webkit-flex;
	display: flex;
	flex: 0 0 220px;
	flex-direction: column;
}
.box-itm {
	background: #222;
	min-height: 200px;
	font-size: 5rem;
	color: #eee;
	margin-bottom: 0px;
	flex: auto;

	display: -webkit-flex;
	display: flex;
	justify-content: center;
	align-items: center;
}
.box-itm:last-child {
	margin-bottom: 0;
}
<div class="box">
		<div class="box-side">
			<div class="box-itm">2 <p>List</p>
      <span class="list-group-item list-group-item-success">Item1</span>
      <span class="list-group-item">Item2</span>
      <span class="list-group-item list-group-item-success">Item3</span>
      <span class="list-group-item">Item4</span>
      <span class="list-group-item list-group-item-success">Item5</span>
      <span class="list-group-item">Item6</span>
      <span class="list-group-item list-group-item-success">Item7</span></div>
			<div class="box-itm" style="background-image: url('http://www.publicdomainpictures.net/download-picture.php?adresar=10000&soubor=abstract-black-background-29541280862230sD05.jpg');background-size: cover;">3</div>
		</div>
		<div class="box-base">1 <p>Table</p>
      <table class="table table-striped table-bordered table-hover">
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
         <tr>
            <td class="info">Row</td>
            <td class="info">Row</td>
         </tr>
      </table></div>
	</div>

<div></div>

Let me offer approach with flexbox. Img is included as background in Div №3. In fullscreen mode you can see a work of snippet. I should note flexbox formatting are included into Bootstrap 4. I suppose my decision will be useful for you.

Upvotes: 2

Sagar Pawar
Sagar Pawar

Reputation: 475

try to put your image into another span tag after item7. it will center the image and will take auto size of the image.

<span class="list-group-item center-block ">
   <img class="img-circle " src="img/img.jpg"  >
</span> 

Upvotes: 0

Related Questions