How do I implement MDL table within a card and get the table to scroll? - css

I am trying to duplicate the UI here: http://www.google.com/design/spec/components/data-tables.html#data-tables-tables-within-cards
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--12-col">
<div class="mdl-card mdl-shadow--4dp" style="width:100%">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Header</h2>
</div>
<div class="mdl-card__supporting-text">
<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
How do I get card container's width to wrap around the table?
When the screen is small and the table is too long, how do I get the table to scroll within the card? Or even get the card to scroll in the page?
I am also unsure how to get this configuration to work:
------------------
| 8 | 4 |
------------------
With a table within a card inside the 8 and the 4 grid. However I think if I can get it to stretch over a 12 grid it will work for 8/4.

Related

overflow issue in divided page into two equal parts bootstrap

he guys i have a annoying issue i need your help i have a picture which size is:
W:814px
H:685
should be placed on the left side of the page ,I have a table which should be placed on the right side of the page,I thought I can achieve it with a simple bootstrap below:
<div class="container">
<div class="row">
<div class="col-sm-6">
<img src="" alt="">
</div>
<div class="col-sm-6">
<table>
</table>
</div>
</div>
</div>
but it becomes like the screen shot i have added here
i dont wana change the size of the pic
Here everything looks better with bootstrap latest version! Could you inspect your page
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-sm-6">
<img src="https://unsplash.it/640/425" class="img-fluid"/>
</div>
<div class="col-sm-6">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td colspan="2">Larry the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

Razor: Table does not expand when a large screen is used

I am using in my ASP .NET Razor Page and it scales very nicely when i decrease the width of my browser. However, when i increase the width of my browser, it does not increase anymore. I want it to increase in size as it has too much white space on the sides.
In the code below i tried style="width:100%" or even changing the margins but it doesn't scale due to large screens. I also tried using container-fluid class and it doesn't work. Need a solution.
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Name</th>
</tr>
</thead>
<tr>
<td>1</td>
<td>Bob</td>
</tr>
<tr>
<td>2</td>
<td>Bobby</td>
</tr>
</table>
Try setting the display as table
display:table
If the table is inside any other tags like div, try setting it width to 100% as well and the display of div is block
Did you put the table in a container-flex? (Bootstrap 4) If not the 100% table width is the same as the normal Bootstrap container width where the table is in.
<div class="container-flex">
<div class="row">
<div class="col">
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Name</th>
</tr>
</thead>
<tr>
<td>1</td>
<td>Bob</td>
</tr>
<tr>
<td>2</td>
<td>Bobby</td>
</tr>
</table>
</div>
</div>
</div>

Bootstrap grid system inside table

<div class="table-responsive">
<table class="table">
<thead>
Head
</thead>
<tbody>
<tr>
<td>
<div class="row">
<div class="col-lg-6">Item 1.0</div>
<div class="col-lg-6">Item 1.1</div>
</div>
</td>
<td>
<div class="row">
<div class="col-lg-6">Item 2.0</div>
<div class="col-lg-6">Item 2.1</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
This code creates a table where all items are in the same line. I have searched the css file but there is nowhere defined inline or inline-block, so I guess this is normal bootstrap behavior. What I am trying to achieve is to show items with prefix 1 one after another and same for items with prefix 2, but I want them all in same row. I have tried using <ul> with <li> elements, but they are also showed in the same line for some reason.
My table should contain only two columns and one header above them all. This is what I get now:
Issue is due to column classes - col-lg-6 which makes divs use equal width of parent td, use class col-lg-12 to use complete td width, please check the css of these classes below
.col-lg-12 {
width: 100%;
}
.col-lg-12 {
width: 50%;
}
Run below code
favorite
<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.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="table-responsive">
<table class="table">
<thead>
Head
</thead>
<tbody>
<tr>
<td>
<div class="row">
<div class="col-lg-12">Item 1.0</div>
<div class="col-lg-12">Item 1.1</div>
</div>
</td>
<td>
<div class="row">
<div class="col-lg-12">Item 2.0</div>
<div class="col-lg-12">Item 2.1</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
codepen for reference - https://codepen.io/nagasai/pen/xybpMm
I don't understand yet why you need to use bootstrap grid system inside the table when the td's are designed to work like that. You're also using col-lg-6 which is equivalent to 2 td's inside 1 tr since there is no collapse (lg).
You'll have a similar output if you use this code;
<h6>Default:</h6>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th colspan='2'>
Head
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Item 1.0
</td>
<td>
Item 1.1
</td>
</tr>
<tr>
<td>
Item 2.0
</td>
<td>
Item 2.1
</td>
</tr>
</tbody>
</table>
</div>
<br>
<h6>Two Columns Only:</h6>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th colspan='4'>
Head
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Item 1.0
</td>
<td>
Item 1.1
</td>
<td>
Item 2.0
</td>
<td>
Item 2.1
</td>
</tr>
</tbody>
</table>
</div>

How to float these C3 chart and HandsOnTable elements without impacting features?

I have a HandsOnTable table (with a couple of additions for user-requests) and a C3 chart (which needs to fill horizontal space) and can't get them living alongside each other nicely.
https://jsfiddle.net/horacebury/2vc606wx/13/
I /think/ these two DIVs should be able to be floated, but when I do they either don't (float) or stop the tooltip of the C3 chart OR stop some of the middle column editing from working:
<div>
<table class="tgh"><tr><td>Auxilliary Power</td></tr></table>
<div id="example"></div>
<table class="tg">
<tr>
<td class="tg-yw4l" ng-repeat="item in items track by $index">{{item}}</td>
</tr>
</table>
</div>
<div id="c3chart"></div>
Not sure how I did this, but I'm pretty sure it's a bodge:
https://jsfiddle.net/horacebury/2vc606wx/15/
<div style="float: right;">
<table class="tgh">
<tr>
<td>Auxilliary Power</td>
</tr>
</table>
<div id="example"></div>
<table class="tg">
<tr>
<td class="tg-yw4l" ng-repeat="item in items track by $index">{{item}}</td>
</tr>
</table>
</div>
<div id="c3chart" style="width: 65%;"></div>

semantic UI - Table - Centre Alignment

Why is centre alignment not working on ?
I was expecting the text to be centre aligned when i specify the class "center aligned" to my element but it does not.
However, if I specify the same class on all elements then it works.
Shouldn't it suffice when a class is specified at and all childrens inherit?
A fiddle is at http://jsfiddle.net/4woemsjt/4/
Basically this one does not work.
<div class="ui grid centered">
<div class="fourteen wide column">
<table class="ui celled collapsing table">
<thead>
<tr class="center aligned">
<th class="three wide">S1</th>
<th class="three wide">S2</th>
<th class="two wide">S3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
</div>
But this one does
<div class="ui grid centered">
<div class="fourteen wide column">
<table class="ui celled collapsing table">
<thead>
<tr>
<th class="center aligned three wide">S1</th>
<th class="center aligned three wide">S2</th>
<th class="center aligned two wide">S3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
</div>
you need to add the "center aligned" to all th-elements.
".ui.table thead th" has "text-align:left" set as default in the .css file.

Resources