Hey i've got the following problem when i am trying to use the bootsrap 4 responsive table.
If there isnt evenough in the table to fill the complete width its look like this.
Layout of Table
My code is the following:
<div class="container" id="maincontainer">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<p>Bevorstehende Veranstaltungen:</p>
<table class="table table-responsive table-hover">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<p>Vergangene Veranstaltungen:</p>
<table class="table table-responsive table-hover">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">30.06.2017 15:30 - 16:00</th>
<td>2/2</td>
<td>dafdfsfa</td>
<td>97</td>
</tr>
</tbody>
</table>
</div>
I hope anyone can help me.
Best Regards
Alex
That's because you have 2 separate tables with 2 different lengths of text in the first column. The only way I can think to make the first columns exactly the same width is to have the exact same amount of characters in them, i.e. add a date and time stamp to the first table.
You can set width in js also, give same width
like
$('.table').dataTable( {
"columnDefs": [
{ "width": "30%" },
{ "width": "20%" },
{ "width": "20%" },
{ "width": "30%" },
]
} )
In bootstrap table, the width of the column will be depends on the data.
If you want columns on both table as same width, I think the <div> may be useful instead of Table.
<p>Bevorstehende Veranstaltungen:</p>
<div class="row">
<div class="col-md-3">
<b>#</b>
</div>
<div class="col-md-3">
<b> First Name</b>
</div>
<div class="col-md-3">
<b> Last Name</b>
</div>
<div class="col-md-3">
<b>Username</b>
</div>
</div>
<br />
<p>Bevorstehende Veranstaltungen:</p>
<div class="row">
<div class="col-md-3">
<b>#</b>
</div>
<div class="col-md-3">
<b> First Name</b>
</div>
<div class="col-md-3">
<b> Last Name</b>
</div>
<div class="col-md-3">
<b>Username</b>
</div>
</div>
<div class="row primary-bordered-table">
<div class="col-md-3">
30.06.2017 15:30 - 16:00
</div>
<div class="col-md-3">
2/2
</div>
<div class="col-md-3">
dafdfsfa
</div>
<div class="col-md-3">
97
</div>
</div>
Then the column will be like in the following image
Related
I am re-doing the front-end of an application using bootstrap 4. The application uses tables in some places that I wish it didn't so I am re-working those tables into a .row/.col grid system. The nice part about tables in bootstrap is that there appear to be styling options available for tables but none seem to exist for rows and columns. You can see in the snippet that it's automatically styling the table but how can I do that using grid?
For example:
<!DOCTYPE html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<body>
<table class="table table-striped">
<thead class="thead-light">
<th>Thing one</th>
<th>Thing two</th>
<th>Thing Three</th>
</thead>
<tbody>
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
</tr>
<tr>
<td>Four</td>
<td>Five</td>
<td>Six</td>
</tr>
<tr>
<td>Seven</td>
<td>Eight</td>
<td>Nine</td>
</tr>
</tbody>
</table>
<div class="container">
<div class="row">
<div class="col">
Thing one
</div>
<div class="col">
Thing two
</div>
<div class="col">
Thing three
</div>
</div>
<div class="row">
<div class="col">
One
</div>
<div class="col">
Two
</div>
<div class="col">
Three
</div>
</div>
<div class="row">
<div class="col">
Four
</div>
<div class="col">
Five
</div>
<div class="col">
Six
</div>
</div>
<div class="row">
<div class="col">
Seven
</div>
<div class="col">
Eight
</div>
<div class="col">
Nine
</div>
</div>
</div>
</body>
You'd add CSS to get the same styles...
.grid-striped .row:nth-of-type(odd) {
background-color: rgba(0,0,0,.05);
}
Or, use the Bootstrap 4 utilities (ie: font-weight-bold, bg-light, etc..) but these would need to be applied individually and won't automatically alternate odd rows like the CSS above.
Demo: https://www.codeply.com/go/IDBemcEAyL
Also remember that table columns can use the grid
I'm trying to create a complex layout using table in twitter-bootstrap. However, I'm not able to get it perfectly right! Particularly, where 5 is displayed!
Is it possible to achieve the same using div's instead? How would I get the borders in that case?
Please check the design attached.
<div class="container">
<table class="table table-bordered" style="width:80%">
<tr>
<td class="col-md-6" colspan="4"><strong>1</strong></td>
<td class="col-md-4" rowspan="3"><img src="#" /></td>
<td class="col-md-2" rowspan="3"><button class="del-icon">X</button></td>
</tr>
<tr>
<td class="col-md-3"><strong>2</strong></td>
<td class="col-md-3"><strong>3</strong></td>
</tr>
<tr>
<td><strong>4</strong></td>
<td><strong>5</strong></td>
</tr>
</table>
</div>
Yes it is possible, you just add row to 2,3 then another row for 4,5
<div class="row">
<div class="col-md-6 blue1">
1
<div class="row">
<div class="col-md-6 blue2">2</div>
<div class="col-md-6 blue3">3</div>
</div>
<div class="row">
<div class="col-md-2 blue4">4</div>
<div class="col-md-10 blue5">5</div>
</div>
</div>
<div class="col-md-4 blue6">
img
</div>
<div class="col-md-2 blue7">
x
</div>
Bootply: http://www.bootply.com/mraM3WKCvt
Hope that helps, cheerio!
There is a gap between elements of an input group, if put into a table.
<link href="https://rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet"/>
<p>This is fine</p>
<div class="row">
<div class="col-xs-4">
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</div>
</div>
<table>
<tr>
<td>There is a gap between spans in tables</td>
</tr>
<tr>
<td>
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</td>
</tr>
</table>
How can I get rid of this gap?
You could try removing the border-spacing added by the table. Alternatively, you can set the border-collapse to collapse if you prefer the way that looks.
border-spacing is inherited by default in CSS by child elements. input-group is set to display: table which means it inherits the borders-spacing: 2px from the parent table. This means it will be applied to input-group-addons since they are being displayed as table cells.
table .input-group {
border-spacing: 0;
}
<link href="https://rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet"/>
<p>This is fine</p>
<div class="row">
<div class="col-xs-4">
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</div>
</div>
<table>
<tr>
<td>Previously a gap between elements</td>
</tr>
<tr>
<td>
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</td>
</tr>
</table>
I want to make an inner div 100% height of the rendered parent div regardless of zoom.
My jsfiddle shows that the shadow div is not the full height as the parent div when I zoom in. How do I cover the parent div completely?
HTML
<div class="container account-settings-confirm-container ng-scope">
<div class="spotlight"></div>
<div class="account-settings-confirm">
<div class="row account-settings-confirm-banner extend-full">
<div class="col-xl-4 col-lg-4 col-md-4 col-sm-4 col-xs-4 text-left banner-user">
<div class="account-settings-confirm-header row">
<div class="account-settings-confirm-body">
<div class="table-responsive">
<table class="table account-settings-confirm-table-products">
<thead>
<tr>
<th>h1</th>
<th>h1</th>
<th>h1</th>
<th>h1</th>
<th>h1</th>
<th>h1</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="6">
<div class="account-settings-confirm-table-container text-center">
button theader <br>
<button id="SetUpStore" class="btn-regular-wide">Button</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div></div>
jsfiddle
https://jsfiddle.net/10nmL3vv/5/
full screen
https://jsfiddle.net/10nmL3vv/5/embedded/result
you can use .height() jQuery for this purpose.
for more related methods you can read this.
http://www.w3schools.com/jquery/css_height.asp
I'am trying to center this:
[![enter image description here][1]][1]
Here is the HTML:
<section class="page-section parallax directions" id="location" style="padding-top:10%">
<div class="container div-table">
<div class="parallax-bg" data-stellar-background-ratio="0.5" data-stellar-vertical-offset="-150"></div>
<div class="parallax-overlay"></div>
<div class="parallax-inner text-center">
<?php
session_start();
if(isset($_SESSION['playername']))
{
?>
<div class="panel panel-warning" style="padding-left:10px;padding-right:10px">
<h3 class='panel-header panel shadow text-center'><?php echo $_SESSION['playername'] ?> UCP</h3>
<div class="panel panel-body">
<table>
<tr>
<td class="text-center">
<h4>My Signature</h4>
</td>
</tr>
<tr>
<td class="text-center">
<h4>My Profile</h4>
</td>
</tr>
<tr>
<td class="text-center">
<h4>Change My Password</h4>
</td>
</tr>
<tr>
<td class="text-center">
<h4>Logout</h4>
</td>
</tr>
</table>
</div>
</div>
<?php
}
else
{
header("location:index.php");
}
?>
</div>
</section>
I'm using bootstrap btw if is thats the matter.
EDIT: i have edited the code above completely which i hasnt shown fully.
try padding-left:auto; and padding-right:auto; instead, 10px is not a lot
Regards
Rachel
How about some simple CSS...
<div class="panel panel-body" style="width:150px;margin:auto;border:1px solid black;">
I put the border on so you could see it better to adjust the width as you need. You can use a percentage in the width also.
create an id for your table, something like mytable and style it like so:
#mytable {
margin-left: auto;
margin-right: auto;
}
Here's the jsfiddle.
use margin:auto on your table
.centerTable {
margin: auto;
}
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="page-section parallax directions" id="location" style="padding-top:10%">
<div class="container div-table">
<div class="parallax-bg" data-stellar-background-ratio="0.5" data-stellar-vertical-offset="-150"></div>
<div class="parallax-overlay"></div>
<div class="parallax-inner text-center">
<div class="panel panel-warning" style="padding-left:10px;padding-right:10px">
<h3 class='panel-header panel shadow text-center'>UCP</h3>
<div class="panel panel-body">
<table class="centerTable">
<tr><td class="text-center"><h4>My Signature</h4></td></tr>
<tr><td class="text-center"><h4>My Profile</h4></td></tr>
<tr><td class="text-center"><h4>Change My Password</h4></td></tr>
<tr><td class="text-center"><h4>Logout</h4></td></tr>
</table>
</div>
</div>
</div>
</div>
</section>
Are you looking for something like this? https://jsfiddle.net/99x50s2s/100/
Use the bootstrap's "text-center" class and also add "table" class to the HTML table.
<div class="panel panel-warning" style="padding-left:10px;padding-right:10px">
<h3 class='panel-header panel shadow text-center'><?php echo $_SESSION['playername'] ?> UCP</h3>
<div class="panel panel-body">
<table class="table">
<tr><td class="text-center"><h4>My Signature</h4></td></tr>
<tr><td class="text-center"><h4>My Profile</h4></td></tr>
<tr><td class="text-center"><h4>Change My Password</h4></td></tr>
<tr><td class="text-center"><h4>Logout</h4></td></tr>
</table>
</div>
</div>