I would like to display two images next to each other inside a bootstrap table, any ideas?
Heres the code,
<tr>
<th scope="row">7</th>
<td></td>
<td>
<img class="img" src="example.jpg" alt="">
<img class="img" src="example.jpg" alt="">
</td>
</tr>
If you want to display images next to each others you can use divinstead of table, because it will be the best practice.
In Bootstrap, every row is divided into 12 columns. You can read this for your clarification about grid system of Bootstrap. You can use any combination to set your images.
6 + 6 = 12
4 + 4 + 4 = 12
3 + 3 + 3 + 3 = 12
-
-
etc
If we take 4 + 4 + 4 = 12 this combination for example. We will be able to set images in any two div. Code will be like this:
<div class="row">
<div class="col-md-4">
<img class="img" src="example.jpg" alt="">
</div>
<div class="col-md-4">
<img class="img" src="example.jpg" alt="">
</div>
<div class="col-md-4">
</div>
</div>
If you want to use table, then firstly read this article. Then code will be like the below:
<table>
<th scope="row">7</th>
<tr>
<td>
<img class="img" src="example.jpg" alt="">
</td>
<td>
<img class="img" src="example.jpg" alt="">
</td>
</tr>
</table>
Hi you can try this simple code for responsive bootstrap table, let me know
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<td><img src="image1.jpg"></td>
<td><img src="image2.jpg"></td>
</tr>
</tbody>
</table>
</div>
You can add the css
img{
display:inline-block;
}
<table>
<th scope="row">7</th>
<tr>
<td>
<img class="img" src="example.jpg" alt="">
<img class="img" src="example.jpg" alt="">
</td>
</tr>
</table>
try this
Try this one out:
<tr>
<th scope="row">7</th>
<td></td>
<td>
<div class="d-flex flex-row flex-nowrap"> <!--div as flexbox with content in a row without wrap-->
<div class="img img-responsive"> <!--responsive img inside div-->
<img class="img img-fluid" src="example.jpg" alt="">
</div>
<div class="img img-responsive"> <!--responsive img inside div-->
<img class="img img-fluid" src="example.jpg" alt="">
</div>
</div>
</td>
</tr>
Related
I'm having a problem with bootstrap- on mobile view the columns stack together but with gaps between them. How can I get rid of the gaps so I can display them in one column?
my code
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-sm-4 col-sm-offset-3 white no-gutters">
<h3>Weather for LA</h3>
</div>
</div>
<div class="row equal">
<div class="col-sm-2 col-sm-offset-3 white col-equal no-gutters">
<img src="https://www.w3schools.com/howto/img_fjords.jpg">
<h3>7 C</h3>
</div>
<div class="col-sm-2 col-equal white no-gutters">
<h4> 01-14-2018</h4>
<table class="table table-striped table-sm">
<tr>
<td>Wind</td>
<td>
<?php echo $wind.'m/s'; ?>
</td>
</tr>
<tr>
<td>Clouds</td>
<td>
<?php echo $cloudiness;?>
</td>
</tr>
<tr>
<td>Pressure</td>
<td>
<?php echo $pressure.' '.'hpa';?>
</td>
</tr>
<tr>
<td>Humidity</td>
<td>
<?php echo $humidity.'%';?>
</td>
</tr>
</table>
</div>
</div>
</div>
Don't use offset in this case. Better to make the position:absolute for the table, which will bring your table in the center of the image.
Assuming that's what you are looking for.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-12">
<h3>Weather for LA</h3>
</div>
</div>
<div class="row equal">
<div class="col-xs-12">
<img src="https://beebom-redkapmedia.netdna-ssl.com/wp-content/uploads/2016/01/Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg" style="width:100%;">
<h3>7 C</h3>
</div>
<div class="col-xs-12" style="position:absolute; padding:5% 20%;">
<h4> 01-14-2018</h4>
<table class="table table-striped table-sm">
<tr>
<td>Wind</td>
<td>
7 mph
</td>
</tr>
<tr>
<td>Clouds</td>
<td>
Light
</td>
</tr>
<tr>
<td>Pressure</td>
<td>
4 Pa
</td>
</tr>
<tr>
<td>Humidity</td>
<td>
12
</td>
</tr>
</table>
</div>
</div>
</div>
This is my code, but the image is above the table, and I want them side-by-side:
<div style="float:left;">
<img src="http://localhost/test1/wp-content/uploads/2017/04/GautengNew-1.gif"; alt="" width="500" height="538" />
</div>
<div style="float:left;">
<table style="margin-left: 10%; float: top;" border="1" width="440">
<tbody>
<!-- Table Rows Here -->
</tbody>
</table>
</div>
See current and desired output:
I think the issue is that you are using <div> rather than <span> tags. If you must use <div> you could either set the second one to float:right or add to their style - display: inline-block;.
Something like this:
<span style="float:left;">
<img src="http://localhost/test1/wp-content/uploads/2017/04/GautengNew-1.gif"; alt="" width="500" height="538" />
</span>
<span style="float:left;">
<table style="margin-left: 10%; float: left;" border="1" width="440">
<tbody>
<!-- Table Rows Here -->
</tbody>
</table>
</span>
or this:
<div style="float:left;display:inline-block;">
<img src="http://localhost/test1/wp-content/uploads/2017/04/GautengNew-1.gif"; alt="" width="500" height="538" />
</div>
<div style="float:left;display:inline-block;">
<table style="margin-left: 10%; float: left;" border="1" width="440">
<tbody>
<!-- Table Rows Here -->
</tbody>
</table>
</div>
So heres my situtation, after I layed out the correct alignments of this emergency contact details of countries, I tried adding json to it. Unfortunately json scambled up my texts. I tried using another col grid inside "col-md-12" to no avail. I also tried bootstrap pull-right and pull-left but the hotline name and the number still does not align properly. I would like to have some advice to what can be done to position the texts.
Here is what its supposed to do: (imagine the flag is in the left side and the number are supposed to be aligned like a column)
Brunei
Ambulance: 991
Police: 993
Fire and Rescue: 995
Search and Rescue: 998
................................................................................................
Here is the current mess of text:
mess of hotlines
Thank you for the time and cooperation to anyone responding
<div class="module-text" ng-controller="VolunteerAidCtrl">
<p class="services-margin">In an emergency, please contact the appropriate service in their respective ASEAN countries for the proper response. These numbers can be called either on landline and mobile and consist of the Police Department, Fire Department, and the Hospital Ambulance. </p>
<hr>
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for..." ng-model="search">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</div>
<hr>
<div class="row">
<div class="col-md-6 services-margin" ng-repeat="service in services | filter:search">
<img class="flagsize" ng-src="{{service.flagimgurl}}">
<div class="country-title col-md-3" ng-bind="service.country"></div>
<p class="col-md-3" ng-bind="service.hl1"></p>
<span class="pull-right" ng-bind="service.hl1num1"></span>
<span class="pull-right" ng-bind="service.hl1num2"></span>
<span class="pull-right" ng-bind="service.hl1num3"></span>
<p ng-bind="service.hl2"></p>
<span class="pull-right" ng-bind="service.hl2num1"></span>
<span class="pull-right" ng-bind="service.hl2num2"></span>
<span class="pull-right" ng-bind="service.hl2num3"></span>
<p ng-bind="service.hl3"></p>
<span class="pull-right" ng-bind="service.hl3num1"></span>
<span class="pull-right" ng-bind="service.hl3num2"></span>
<span class="pull-right" ng-bind="service.hl3num3"></span>
<p ng-bind="service.hl4"></p>
<span class="pull-right" ng-bind="service.hl4num1"></span>
<span class="pull-right" ng-bind="service.hl4num2"></span>
<span class="pull-right" ng-bind="service.hl4num3"></span>
</div>
</div>
</div>
To align the image to the left and have the content on the right I would use the media object
and for proper alignment to right, why not use tables?
<div class="row">
<div class="col-md-6" ng-repeat="service in services | filter:search">
<div class="media">
<div class="media-left">
<a href="#">
<img class="media-object flagsize" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/67/Flag_of_Brunei_1906-1959.svg/1000px-Flag_of_Brunei_1906-1959.svg.png" alt="...">
</a>
</div>
<div class="media-body">
<h4 class="media-heading country-title" ng-bind="service.country">Brunei</h4>
<table class="table">
<tr>
<td ng-bind="service.hl1">Service 1</td>
<td style="text-align:right">
<div ng-bind="service.hl1num1">111</div>
<div ng-bind="service.hl1num2">222</div>
<div ng-bind="service.hl1num3">333</div>
</td>
</tr>
<tr>
<td ng-bind="service.hl2">Service 2</td>
<td style="text-align:right">
<div ng-bind="service.hl2num1">111</div>
<div ng-bind="service.hl2num2">222</div>
<div ng-bind="service.hl2num3">333</div>
</td>
</tr>
<tr>
<td ng-bind="service.hl3">Service 3</td>
<td style="text-align:right">
<div ng-bind="service.hl3num1">111</div>
<div ng-bind="service.hl3num2">222</div>
<div ng-bind="service.hl3num3">333</div>
</td>
</tr>
<tr>
<td ng-bind="service.hl4">Service 4</td>
<td style="text-align:right">
<div ng-bind="service.hl4num1">111</div>
<div ng-bind="service.hl4num2">222</div>
<div ng-bind="service.hl4num3">333</div>
</td>
</tr>
</table>
</div>
</div>
</div>
https://jsfiddle.net/ktbmLaq8/
I am working on site which is based on table-layout (no div). Now requirement change and has to re-create so that it look responsive, and for responsive we choose bootstrap as option.
Now, How can I convert tables layout into bootstrap grid layout so can 1. look not change, 2. have responsive also.
table-layout is too complex in site. lots of nesting is there. For example:
<table border="0" width='100%' bgcolor='#ff00ff'>
<tr style='padding-bottom:1em;'>
<td>
<table border="0">
<tr valign='bottom'>
<td width='50'> </td>
<td>
<img border="0" src="#" width="100" height="300">
</td>
<td width='25'> </td>
<td>
<span style='font-size:10px;color:#cccccc;'>Alpha testing</span>
</td>
</tr>
</table>
</td>
<td align='right'>
<table border="0" cellspacing="0">
<tr>
<td align='center' colspan='3'>
<span>Another tesing text</span>
<span style='color:#FFFFCC;'> - </span>
<span style='font-size:11px;color:#fffff;'>Random text</span>
</td>
</tr>
</table>
</td>
</tr>
For example how can I convert above code with bootstrap row, col-*-* grid-layout.
Trust me, I tried a lot to convert this, but sometime looks change or some time just not work at all.
General suggestion on how to convert table base layout into bootstrap are also welcome.
Here is some great literature: Bootstrap 3 Grid system
Replace table and tbody with div class="container"
Replace tr with div class="row"
Replace td with div class="col-ww-nn"
Where ww is device width (xs, sm, md, lg)
Where nn is a number 1-12 for width percentage (divided by 12)
Below is your updated code (including some syntax fixes too). Note, I've added responsiveness so that on phones (xs devices) your second main column would be a separate line. And you can make images responsive with img-response so that it's size changes with the device.
<div class="container" style="background-color:#ff00ff">
<div class="row">
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-4 col-sm-4">
</div>
<div class="col-xs-4 col-sm-4">
<img src="#" class="img-responsive">
</div>
<div class="col-xs-4 col-sm-4">
</div>
<div class="col-xs-4 col-sm-4">
<span style="font-size:10px;color:#cccccc;">Alpha testing</span>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-4 col-sm-4">
<span>Another tesing text</span>
</div>
<div class="col-xs-4 col-sm-4">
<span style="color:#ffffcc;"> - </span>
</div>
<div class="col-xs-4 col-sm-4">
<span style="font-size:11px;color:#ffffff;">Random text</span>
</div>
</div>
</div>
</div>
</div>
Actually it is not so complex.
Just skip every <table> and <tbody> tag, treat every <tr> as block element with class="row" and every <td> as block element with class="col-*-*". Nesting Bootstrap grid is totally okey, so if you have somthing like that:
<tr style='padding-bottom:1em;'>
<td>
<table border="0">
<tr valign='bottom'>
<td width='50'> </td>
<td>
<img border="0" src="#" width="100" height="300">
</td>
<td width='25'> </td>
<td>
<span style='font-size:10px;color:#cccccc;'>Alpha testing</span>
</td>
</tr>
</table>
</td>
</tr>
Just do:
<div class="row">
<div class="col-xs-6">
<div class="row">
<div class="col-xs-6"> </div>
<div class="col-xs-6">
<img border="0" src="#" width="100" height="300">
</div>
<div class="col-xs-10"> </div>
<div class="col-xs-2">
<span style='font-size:10px;color:#cccccc;'>Alpha testing</span>
</div>
</div>
</div>
</div>
Ofcourse those are just example Bootstrap classes - you don't have to stick with numbers ;)
I trying to design thumbnail using bootstrap 3
I am unable to design the table in that way can you please help me out
<div class="row">
<div class="col-sm-4 col-xs-6">
<div class="thumbnail">
<img src="//placehold.it/450X300/DD66DD/EE77EE" class="img-responsive">
<div class="caption">
<h3>Plot 1</h3>
<p><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span>
Electronic City</p>
<table border="1" class="propertyDetails">
<tr>
<td>Price</td><td>Rs. 1400000</td>
</tr>
<tr>
<td>Total Land</td><td>7 acres</td>
</tr>
<tr>
<td>Total Plots</td><td>154</td>
</tr>
<tr>
<td>Avaliable Plots</td><td>15</td>
</tr>
<tr>
<td colspan="2" align="right"><div class="enquirybuttonclass">
<input class="btn btn-primary" type="button" value="ENQUIRY"></div> </td>
</tr>
</table>
</div>
</div>
</div>
I have attached the image:
Try this:
<div class="row">
<div class="col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-body">
<img src="//placehold.it/450X300/DD66DD/EE77EE" class="img-responsive">
<div class="caption">
<h3>Plot 1</h3>
<p><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span> Electronic City
</p>
</div>
</div>
<table class="table" style="padding: 0; margin: 0;">
<tr>
<td>Price</td>
<td>Rs. 1400000</td>
</tr>
<tr>
<td>Total Land</td>
<td>7 acres</td>
</tr>
<tr>
<td>Total Plots</td>
<td>154</td>
</tr>
<tr>
<td>Avaliable Plots</td>
<td>15</td>
</tr>
</table>
<div class="panel-body">
<input class="btn btn-primary pull-right" type="button" value="ENQUIRY">
</div>
</div>
</div>
</div>
Example
Rather than using the thumbnail class - which is generally just for holding images - I've changed the whole thing to a panel. The first part, including the image, is contained in a "panel-body", the table (now with class "table") has had all padding and margins removed so that it covers the full width, and the button has been removed from the table and put in its own panel with a "pull-right" class to bring it over to the right side.
Remove the border from the table, add the table class and you should be good to go.
<div class="thumbnail">
<img src="//placehold.it/250X100/DD66DD/EE77EE" class="img-responsive">
<div class="caption">
<h3>Plot 1</h3>
<p><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span>
Electronic City</p>
<table class="table">
<tbody><tr>
<td>Price</td><td>Rs. 1400000</td>
</tr>
<tr>
<td>Total Land</td><td>7 acres</td>
</tr>
<tr>
<td>Total Plots</td><td>154</td>
</tr>
<tr>
<td>Avaliable Plots</td><td>15</td>
</tr>
</tbody></table>
<div class="text-right">
<input class="btn btn-primary" value="ENQUIRY" type="button">
</div>
</div></div>
demo