I have a table like so. Within each program, I have multiple forms. Each form has a name, a Default YES/NO field (the tick mark if yes) and a status field ACTIVE/INACTIVE.
The problem is however that my current code messes up the alignment. The red lines indicate all the items that should be aligned in a single row.
My code is as follows:
<div class="scrollContainer">
<div class="fixedHeaderSection">
<table class="table columnHeadings" style="table-layout: fixed">
<tbody>
<tr>
<td class="col-md-4 col-sm-4 col-xs-4">
Program
</td>
<td class="col-md-4 col-sm-4 col-xs-4">
Forms
</td>
<td class="col-md-1 col-sm-1 col-xs-1">
</td>
<td class="col-md-3 col-sm-3 col-xs-3">
Status
</td>
</tr>
</tbody>
</table>
</div>
<div class="scrollableSection">
<table class="table columnData" style="table-layout: fixed">
<tr ng-repeat="program in programsList">
<td style="word-wrap: break-word;" class="col-md-4 col-sm-4 col-xs-4">
{{program.name}}
</td>
<td style="word-wrap: break-word;" class="col-md-4 col-sm-4 col-xs-4">
<li ng-repeat="form in program.forms" style="list-style:none;">
{{form.name}}
</li>
+ New Form
</td>
<td style="word-wrap: break-word;" class="col-md-1 col-sm-1 col-xs-1">
<li ng-repeat="form in program.forms" style="list-style:none;">
<span ng-cloak ng-if="form.default == 'YES'" class="glyphicon glyphicon-ok"></span>
</li>
</td>
<td style="word-wrap: break-word;" class="col-md-3 col-sm-3 col-xs-3">
<li ng-repeat="form in program.forms" style="list-style:none;">
{{form.status}}
</li>
</td>
</tr>
</table>
</div>
How do I fix this?
The problem is most likely that you want your li elements to be aligned in the 'correct' rows. But this is not guaranteed in any way, because long li texts will get broken down, and the list in the next column cannot know about this.
You should consider adding further rows to your table for every form in a program and use rowspan or something on the first column.
Its kinda messy but should get it done.
Link to a "working" plnkr : http://plnkr.co/edit/Q9Ikmo3GVvtm3MdYlPNY?p=preview
<table class="table columnData" style="table-layout: fixed" border="1">
<tr ng-repeat-start="program in programsList">
<td style="word-wrap: break-word;" class="col-md-4 col-sm-4 col-xs-4" rowspan="{{program.forms.length + 1}}">
{{program.name}}
</td>
<td style="word-wrap: break-word;" class="col-md-4 col-sm-4 col-xs-4">
+ New Form
</td>
<td style="word-wrap: break-word;" class="col-md-1 col-sm-1 col-xs-1">
</td>
<td style="word-wrap: break-word;" class="col-md-3 col-sm-3 col-xs-3">
</td>
</tr>
<tr ng-repeat-end ng-repeat="form in program.forms">
<td>
{{form.name}}
</td>
<td><span ng-cloak ng-if="form.default == 'YES'" class="glyphicon glyphicon-ok"></span></td>
<td>{{form.status}}</td>
</tr>
</table>
You can try this. I deleted the li and used "rowspan".
You were using 2 tables, so I correct it whit using only one (thead + tbody)
<div class="scrollContainer">
<table class="table columnHeadings" style="table-layout: fixed">
<div class="fixedHeaderSection">
<thead>
<tr>
<th class="col-md-4 col-sm-4 col-xs-4">
Program
</th>
<th class="col-md-4 col-sm-4 col-xs-4">
Forms
</th>
<th class="col-md-1 col-sm-1 col-xs-1">
</th>
<th class="col-md-3 col-sm-3 col-xs-3">
Status
</th>
</tr>
</thead>
</div>
<tbody>
<div class="scrollableSection">
<tr ng-repeat="program in programsList">
<td rowspan="program.forms.length" style="word-wrap: break-word;" class="col-md-4 col-sm-4 col-xs-4">
{{program.name}}
</td>
<td ng-repeat="form in program.forms" style="word-wrap: break-word;" class="col-md-4 col-sm-4 col-xs-4">
{{form.name}}
+ New Form
</td>
<td ng-repeat="form in program.forms" style="word-wrap: break-word;" class="col-md-1 col-sm-1 col-xs-1">
<span ng-cloak ng-if="form.default == 'YES'" class="glyphicon glyphicon-ok"></span>
</td>
<td ng-repeat="form in program.forms" style="word-wrap: break-word;" class="col-md-3 col-sm-3 col-xs-3">
{{form.status}}
</td>
</tr>
</div>
</tbody>
</table>
If you don't care about restructuring HTML, this might be most simple solution.
<tr ng-repeat="program in programsList">
<td class="col-md-4 col-sm-4 col-xs-4">
{{program.name}}
</td>
<td class="col-xs-8">
<div ng-repeat="form in program.forms">
<div class="col-md-4 col-sm-4 col-xs-4">
{{form.name}}
</div>
<div class="col-md-1 col-sm-1 col-xs-1">
<span ng-cloak ng-if="form.default == 'YES'" class="glyphicon glyphicon-ok"></span>
</div>
<div class="col-md-3 col-sm-3 col-xs-3">
{{form.status}}
</div>
</div>
<div>
+ New Form
</div>
</td>
</tr>
This example might need to be adjust a little bit because this is without test. The point is to use single loop for 'program.forms'.
Related
In the following, how do I set all cards to have same widths? I currently see some cards exceeding the specified width because of the the table it is holding. I am viewing it on a laptop.
<main role="main" class="container">
<div class="container">
<div class="main-body">
<div class="row gutters-sm">
<div class="col-md-15">
<div class="card mb-3">
<div class="card-body">
<!-- stuff here-->
</div>
</div>
</div>
</div>
<div class="row gutters-sm">
<div class="col-md-15">
<div class="card mb-3">
<div class="card-body">
<!-- stuff here-->
</div> <!--end of card-->
</div>
</div>
</div>
<div class="row gutters-sm">
<div class="col-md-15">
<div class="card mb-3">
<div class="card-body">
<table class="table mb-0 table-hover">
<thead class="bg-primary">
<tr>
<th scope="col">SSSSSS</th>
<th scope="col">DDDDDD</th>
<th scope="col">FFFFFF</th>
<th scope="col">TTTTTT</th>
<th scope="col">GGGGGGGGG</th>
<th scope="col">AAAAAA</th>
</tr>
</thead>
<tbody>
<tr>
<td class="mb-0"><div class="col-md-1 text-secondary">String 1 </div></td>
<td class="mb-0"><div class="col-md-1 text-secondary">String 2 </div></td>
<td class="mb-0"><div class="col-md-1 text-secondary">String 3</div></td>
<td class="mb-0"><div class="col-md-1 text-secondary">String 4</div></td>
<td class="mb-0"><div class="col-md-1 text-secondary">TTTT </div></td>
<td class="mb-0">
<div class="col-sm-12">
<a class="btn btn-secondary " name="education" href="/edit/2">Edit</a>
<a class="btn btn-danger " name="education" href="/delete/2">Delete</a>
</div>
</td>
</tr>
</tbody>
</table>
<!-- stuff here-->
</div> <!--end of card body-->
</div>
</div>
</div>
</div>
</div>
</main>
I made a collapsible table and I'm using datatable from bootstrap. Unfortunately, it messed up the original position of the rows. It should be like this :
But when i used the datatable, the position changed, the collapsed contents are at the top like this :
Is there a way to maintain the original position while I'm still using datatable? Cause that seems to be the source of the problem.
Here is the HTML of the table and how i called the datatable :
<table id="mytable" class="table table-hover table-light">
<thead>
<tr>
<th scope="col">Kode Transaksi</th>
<th scope="col">Customer</th>
<th scope="col">Total</th>
<th scope="col">Bayar</th>
<th scope="col">Kembali</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr>
<td>T15072022101</td>
<td>Nama Customer</td>
<td>Rp. 50.000</td>
<td>- Rp. 50.000</td>
<td>Rp. 0</td>
<td>
<div class="col text-left">
<button type="button" class="btn btn-primary" onclick="#">
<span><i class="fa fa-edit"></i>Print</span>
</button>
<button type="button" class="btn btn-link" onclick="#" data-toggle="collapse" data-target="#tr1" aria-expanded="false" aria-controls="tr1">
<span><i class="fa fa-angle-down"></i></span>
</button>
</div>
</td>
</tr>
<tr class="collapse" id="tr1">
<td colspan="6">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-sm text-left">
<p style="font-weight:500">Kasir : Ria</p>
<p style="font-size:12px;color:grey;font-weight:500"></p>
</div>
<div class="col-sm text-right">
<p>Total Barang : 4</p>
</div>
</div>
<table class="table table-hover table-light">
<tbody>
<tr>
<td class="align-middle">1</td>
<td class="align-middle">Nama Barang 1</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Jumlah</p>
<p style="font-weight:500;">2 pcs</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Harga</p>
<p style="font-weight:500;">Rp. 15.000</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Total</p>
<p style="font-weight:500;">Rp. 30.000</p>
</div>
</td>
</tr>
<tr>
<td class="align-middle">2</td>
<td class="align-middle">Nama Barang 2</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Jumlah</p>
<p style="font-weight:500;">2 pcs</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Harga</p>
<p style="font-weight:500;">Rp. 10.000</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Total</p>
<p style="font-weight:500;">Rp. 20.000</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
</tr>
<tr>
<td>T15072022103</td>
<td>Nama Customer 2</td>
<td>Rp. 100.000</td>
<td>- Rp. 100.000</td>
<td>Rp. 0</td>
<td>
<div class="col text-left">
<button type="button" class="btn btn-primary" onclick="#">
<span><i class="fa fa-edit"></i>Print</span>
</button>
<button type="button" class="btn btn-link" onclick="#" data-toggle="collapse" data-target="#tr2" aria-expanded="false" aria-controls="tr2">
<span><i class="fa fa-angle-down"></i></span>
</button>
</div>
</td>
</tr>
<tr class="collapse" id="tr2">
<td colspan=6>
<div class="row d-flex justify-content-center align-items-center">
<div class="col-sm text-left">
<p style="font-weight:500">Kasir : Maliachi</p>
<p style="font-size:12px;color:grey;font-weight:500"></p>
</div>
<div class="col-sm text-right">
<p>Total Barang : 7</p>
</div>
</div>
<table class="table table-hover table-light">
<tbody>
<tr>
<td class="align-middle">1</td>
<td class="align-middle">Nama Barang 1</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Jumlah</p>
<p style="font-weight:500;">5 pcs</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Harga</p>
<p style="font-weight:500;">Rp. 10.000</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Total</p>
<p style="font-weight:500;">Rp. 50.000</p>
</div>
</td>
</tr>
<tr>
<td class="align-middle">2</td>
<td class="align-middle">Nama Barang 2</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Jumlah</p>
<p style="font-weight:500;">2 pcs</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Harga</p>
<p style="font-weight:500;">Rp. 25.000</p>
</div>
</td>
<td class="align-middle">
<div class="col-sm text-left">
<p style="font-weight:500;font-size:12px;color:grey;">Total</p>
<p style="font-weight:500;">Rp. 50.000</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
<td style="padding:0rem;"></td>
</tr>
</tbody></table>
Here is the JS to call the datatable :
$(document).ready(function () {
$('#mytable').DataTable();
});
Here are the required script for datatable:
<!-- datatables -->
<script
src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script
src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap4.min.js"></script>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css">
<link rel="stylesheet"
href="https://cdn.datatables.net/1.12.1/css/dataTables.bootstrap4.min.css">
Any help would be appreciated , thanks!
I've got three columns in one row. Each column is lg-6, which makes the last column span below the other two. This column is placed to the right using float-right. But whenever the column above the last column (Column 2) gets more content than the first column, the last column (Column 3) are moved to the left (as showed in the photo below). Is there any way to prevent the column being moved like this? Force it to stay right.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row d-md-block mt-4 mx-n3 px-4">
<div class="card col-lg-6 col-sm-12 mx-n1 float-left">
<div class="card-header screensCardHeader">
<h4 class="m-0 font-weight-bold text-header">Column 1</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="table_0_view" class="table" width="100%" cellspacing="0">
<thead class="screensThead">
<tr>
<th>#</th>
<th>Namn</th>
</tr>
</thead>
<tbody id="tbody_0_view" class="screenstable screenstableque">
<tr id="2" sport="0" class="screenstablerow">
<td class="viewtd row-id-0">1</td>
<td>Person 1</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="card col-lg-6 col-sm-12 mx-n1 float-right order-1">
<div class="card-header screensCardHeader">
<h4 class="m-0 font-weight-bold text-header">Column 2</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="table_1_view" class="table" width="100%" cellspacing="0">
<thead class="screensThead">
<tr>
<th>#</th>
<th>Namn</th>
</tr>
</thead>
<tbody id="tbody_1_view" class="screenstable screenstableque">
<tr id="3" sport="1" class="screenstablerow">
<td class="viewtd row-id-1">1</td>
<td>Person 2</td>
</tr>
<tr id="4" sport="1" class="screenstablerow">
<td class="viewtd row-id-1">1</td>
<td>Person 3</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="card col-lg-6 col-sm-12 mx-n1 float-right justify-content-end">
<div class="card-header screensCardHeader">
<h4 class="m-0 font-weight-bold text-header">Column 3</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="table_2_view" class="table" width="100%" cellspacing="0">
<thead class="screensThead">
<tr>
<th>#</th>
<th>Namn</th>
</tr>
</thead>
<tbody id="tbody_2_view" class="screenstable screenstableque">
</tbody>
</table>
</div>
</div>
</div>
</div>
Don't use float property, instead use d-flex in the parent.
And use ml-auto in column 3
UPDATE - regarding OP comments
But this means that Column 1 will follow the height of column 2 right? Is there any way to hide the whitespace appearing in Column 1 when adding stuff in column 2 then?
Answer: use align-items-start in the row div
Also, the spacing between right and left column seems to disappear. I used a negative margin of 1 with mx-n1 earlier. Any way to get this back while using d-flex? Used according to documentation of last bootstrap, negative margin: getbootstrap.com/docs/4.5/utilities/spacing
Answer: Use the card utility class inside of col-*-* instead of using it along with
N.B. : width and cellspacing attributes are deprecated
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row d-flex mt-4 px-4 align-items-start">
<div class="col-lg-6 col-sm-12 mb-4">
<div class="card">
<div class="card-header screensCardHeader">
<h4 class="m-0 font-weight-bold text-header">Column 1</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="table_0_view" class="table">
<thead class="screensThead">
<tr>
<th>#</th>
<th>Namn</th>
</tr>
</thead>
<tbody id="tbody_0_view" class="screenstable screenstableque">
<tr id="2" sport="0" class="screenstablerow">
<td class="viewtd row-id-0">1</td>
<td>Person 1</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12 mb-4">
<div class="card">
<div class="card-header screensCardHeader">
<h4 class="m-0 font-weight-bold text-header">Column 2</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="table_1_view" class="table">
<thead class="screensThead">
<tr>
<th>#</th>
<th>Namn</th>
</tr>
</thead>
<tbody id="tbody_1_view" class="screenstable screenstableque">
<tr id="3" sport="1" class="screenstablerow">
<td class="viewtd row-id-1">1</td>
<td>Person 2</td>
</tr>
<tr id="4" sport="1" class="screenstablerow">
<td class="viewtd row-id-1">1</td>
<td>Person 3</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12 ml-auto mb-4">
<div class="card">
<div class="card-header screensCardHeader">
<h4 class="m-0 font-weight-bold text-header">Column 3</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="table_2_view" class="table">
<thead class="screensThead">
<tr>
<th>#</th>
<th>Namn</th>
</tr>
</thead>
<tbody id="tbody_2_view" class="screenstable screenstableque">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
I would like to display two rows (tr) on the same line with equal width. I tried adding col-sm-6 to the tds, but it's the trs are getting displayed on two separate lines. Here's the html:
<div className="jumbotron col-sm-12 text-left row">
<div className="panel panel-info">
<div className="panel-heading">
HEADER
</div>
</div>
<table className="table table-bordered table-condensed table-responsive">
<tbody>
<tr>
<td className="col-sm-6 col-centered leftCol">
<div>
{"hello1"}
</div>
</td>
</tr>
<tr>
<td className="col-sm-6 col-centered rightCol">
<div>
{'hello2'}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
You will have to insert class col-sm-6 for tr tags if you want them on same line.
Here is the working fiddle of your code
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div className="jumbotron col-sm-12 text-left row">
<div className="panel panel-info">
<div className="panel-heading">
HEADER
</div>
</div>
<table className="table table-bordered table-condensed table-responsive">
<tbody>
<tr class="col-sm-6">
<td className="col-centered leftCol">
<div>
{"hello1"}
</div>
</td>
</tr>
<tr class="col-sm-6">
<td className="col-centered rightCol">
<div>
{'hello2'}
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div className="jumbotron col-sm-12 text-left row">
<div className="panel panel-info">
<div className="panel-heading">
HEADER
</div>
</div>
<table className="table table-bordered table-condensed table-responsive">
<tbody>
<tr>
<td className="col-sm-6 col-centered leftCol" style="height: 200px;">
<div>
{"hello1"}
</div>
</td>
</tr>
<tr>
<td className="col-sm-6 col-centered rightCol" style="height: 200px;">
<div>
{'hello2'}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
Adding style will do it.
<div className="jumbotron col-sm-12 text-left row">
<div className="panel panel-info">
<div className="panel-heading">
HEADER
</div>
</div>
<table className="table table-bordered table-condensed table-responsive">
<tbody>
<tr>
<td className="col-sm-6 col-centered leftCol">
<div>
{"hello1"}
</div>
</td>
<td className="col-sm-6 col-centered rightCol">
<div>
{'hello2'}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
I expect something like this:
|-----------panel-heading---------------------|
| | Name | Sex | |
| wrap-word | wrap-word |
| wrap-word |
but as you can see, the long word 111... and 222... does not wrap and the table is longer than panel
How to fix it?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-heading">test </div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Sex</th>
<th></th>
</tr>
</thead>
<tbody>
<tr >
<td>ff</td>
<td>wer</td>
<td>1</td>
<td>asdf</td>
</tr>
<tr class="">
<td colspan="4">
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-md-6 col-xs-12"> <h2 style="word-wrap: break-word">11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</h2>
</div>
<div class="col-lg-6 col-md-6 col-xs-12"> <h2 style="word-wrap: break-word">22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222</h2>
<hr>
</div>
</div>
<div class="row"> <h2 style="word-wrap: break-word">33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333</h2>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
You can make the words (long strings) break with word-break: break-word; in addition to your word-wrap like this:
h2 {
word-wrap: break-word;
word-break: break-word;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-heading">test </div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Sex</th>
<th></th>
</tr>
</thead>
<tbody>
<tr >
<td>ff</td>
<td>wer</td>
<td>1</td>
<td>asdf</td>
</tr>
<tr class="">
<td colspan="4">
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-md-6 col-xs-12"><h2>11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</h2>
</div>
<div class="col-lg-6 col-md-6 col-xs-12"><h2>22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222</h2>
<hr>
</div>
</div>
<div class="row"><h2>33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333</h2>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
This will also work on other elements like divs, spans etc.
What's the difference between word-wrap and word-break?
word-wrap: The word-wrap CSS property is used to specify whether or not the browser may break lines within words in order to prevent overflow when an otherwise unbreakable string is too long to fit in its containing box.
word-break: The word-break CSS property is used to specify how (or if) to break lines within words
In conclusion you need them both to break long strings without any spaces where the word-wrap could take in place.
Use table-layout:fixed this will wrap the table within the width of the parent div and text will break automatically.
table{
table-layout:fixed;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-heading">test </div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Sex</th>
<th></th>
</tr>
</thead>
<tbody>
<tr >
<td>ff</td>
<td>wer</td>
<td>1</td>
<td>asdf</td>
</tr>
<tr class="">
<td colspan="4">
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-md-6 col-xs-12"> <h2 style="word-wrap: break-word">11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</h2>
</div>
<div class="col-lg-6 col-md-6 col-xs-12"> <h2 style="word-wrap: break-word">22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222</h2>
<hr>
</div>
</div>
<div class="row"> <h2 style="word-wrap: break-word">33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333</h2>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>