Floating horizontal scrollbar with mat-table in AngularHow to horizontally center a <div>?Scrollbar affecting the div widthFixed header table with horizontal scrollbar and vertical scrollbar onHtml table with fixed header and vertical scrollbars on the table bodyHow to Center the Content inside Mat-Card Component - Angular 6Align mat-cards content (image, text and buttons)Angular Material Table with Sticky and Custom Width ColumnScrollbar is not shown in mat-tabs angular material 6How can I get a mat-table to resize automatically to fit headersVertical scroll bar and fixed headers with mat-table

Hot coffee brewing solutions for deep woods camping

How do I set an alias to a terminal line?

Why cruise at 7000' in an A319?

Why do all the teams that I have worked with always finish a sprint without completion of all the stories?

How dangerous are set-size assumptions?

Find the probability that the 8th woman to appear is in 17th position.

How much will studying magic in an academy cost?

How long would it take to cross the Channel in 1890's?

How do I respond to requests for a "guarantee" not to leave after a few months?

Why is the high-pass filter result in a discrete wavelet transform (DWT) downsampled?

Set multicolumn to a exact width

Apply brace expansion in "reverse order"

Does this Wild Magic result affect the sorcerer or just other creatures?

Can ADFS connect to other SSO services?

Sci fi short story, robot city that nags people about health

What is the legal status of travelling with methadone in your carry-on?

Do I have any obligations to my PhD supervisor's requests after I have graduated?

Links to webpages in books

What does "play with your toy’s toys" mean?

Can humans ever directly see a few photons at a time? Can a human see a single photon?

Swapping rooks in a 4x4 board

Why is C++ initial allocation so much larger than C's?

How to get cool night-vision without lame drawbacks?

How risky is real estate?



Floating horizontal scrollbar with mat-table in Angular


How to horizontally center a <div>?Scrollbar affecting the div widthFixed header table with horizontal scrollbar and vertical scrollbar onHtml table with fixed header and vertical scrollbars on the table bodyHow to Center the Content inside Mat-Card Component - Angular 6Align mat-cards content (image, text and buttons)Angular Material Table with Sticky and Custom Width ColumnScrollbar is not shown in mat-tabs angular material 6How can I get a mat-table to resize automatically to fit headersVertical scroll bar and fixed headers with mat-table






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















Is it possible to add a floating horizontal scrollbar to a mat-table in Angular 7 without JQuery or any other additional plugins?



I have a mat-table that shows 6 columns but also can dynamically add 100+ columns with the push of a button.
But then the layout breaks.



HTML-Part:



<button (click)="showLess()" mat-stroked-button class="show-button">Show Less</button>
<button (click)="showMore()" mat-stroked-button class="show-button">Show More</button>

<div class="component data component-card">
<mat-card *ngIf="dataSource?.filteredData" class="mat-card">
<mat-paginator [length]="length" [pageSize]="100" [pageSizeOptions]="[100, 250, 500, 1000, 2000]" showFirstLastButtons> </mat-paginator>
<mat-table [dataSource]="dataSource" matSort class="table">
<ng-container class="container" *ngFor="let displayedColumn of displayedColumns" matColumnDef=" displayedColumn ">
<mat-header-cell class="header-cell" *matHeaderCellDef >
<span mat-sort-header class="sort-header"> uppercase </span>
<input class="table-input" matInput (keyup)="applyFilter($event.target.value)" (focus)="setupFilter(displayedColumn)" placeholder="Filter"/>
</mat-header-cell>
<mat-cell class="cell" *matCellDef="let item"> item[displayedColumn] </mat-cell>
</ng-container>
<mat-header-row class="header-row" *matHeaderRowDef="displayedColumns; sticky: true"></mat-header-row>
<mat-row class="row" *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</mat-card>




CSS-Part:



.data 
display: block;
width: 95vw;
overflow: auto;

.table
width: 100vw;
max-width: 100%;
overflow: auto;
margin-bottom: 10px;
display: table;
border-collapse: collapse;
margin: 0px;
background-color: rgb(238, 238, 238);

.row,
.header-row
display: table-row;
min-height: 36px !important;

.cell,
.header-cell
word-wrap: initial;
display: table-cell;
padding: 0px 5px;
line-break: unset;
width: fit-content;
white-space: nowrap;
overflow: hidden;
vertical-align: middle;
text-align: center;

.header-row,
.header-cell
margin: 0 auto;
min-height: 100px !important;
text-align: center;
vertical-align: middle;
align-self: center;

.sort-header
display: flex;
align-content: center;
text-align: center;
justify-content: center;
font-size: 12pt;

.header-cell
font-weight: bold;



.mat-card
min-width: max-content;
max-width: max-content;



If the overflows are both active then I have to scroll down to be able to scroll horizontally but the layout stays as it should. Only the mat-table and the div around it it will be scrolled and the elements above the mat-table (search fields etc.) are staying where they should. Everything stays in the middle of the screen.



If I deactivate the overflow from the div in the ".data" then the normal browser scrollbar appears and I don't have to scroll down anymore. But the mat-table expands the screen to the right on scrolling and the search fields above will stay on the left when scrolling horizontally which for me breaks the layout.



What I need would be a combination of both scrollbars which would be a floating scrollbar in my eyes. I would only scroll the mat-table but the rest stays in place.



Is there a way to accomplish that natively with CSS or Angular?



Demo:
https://stackblitz.com/edit/angular-elm867?file=src%2Fapp%2Fapp.component.scss



If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".



Here's an image on how the table scrollbar should replace the normal scrollbar: enter image description here










share|improve this question



















  • 2





    Please create a stackblitz demo for the problem

    – Abhishek Kumar
    Mar 25 at 9:44











  • stackblitz.com/edit/… If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".

    – suckerp
    Mar 25 at 10:22












  • If this is what you need ? See : stackblitz.com/edit/angular-horizontal-alignment?file=src/app/… , or suggest, i can change accordingly

    – Abhishek Kumar
    Mar 25 at 10:42











  • Thanks. The outer scrollbar should behave like the inner one and only one scrollbar should be visible. The inner scrollbar is the one from ".data". Not sure if the "overflow" from ".table" has an effect. I populated the table with more data to make it clearer. When scrolling horizontally the table data / headers should move left / right and the buttons in this example need to stay always visible. Both happens with "overflow" activated in ".data". But the scrollbar should be at the bottom of the browser and not at the end of the table.

    – suckerp
    Mar 25 at 11:48











  • Also it would be great if the paginator could float along with the scrolling always staying on the right of the actual view.

    – suckerp
    Mar 25 at 11:49

















2















Is it possible to add a floating horizontal scrollbar to a mat-table in Angular 7 without JQuery or any other additional plugins?



I have a mat-table that shows 6 columns but also can dynamically add 100+ columns with the push of a button.
But then the layout breaks.



HTML-Part:



<button (click)="showLess()" mat-stroked-button class="show-button">Show Less</button>
<button (click)="showMore()" mat-stroked-button class="show-button">Show More</button>

<div class="component data component-card">
<mat-card *ngIf="dataSource?.filteredData" class="mat-card">
<mat-paginator [length]="length" [pageSize]="100" [pageSizeOptions]="[100, 250, 500, 1000, 2000]" showFirstLastButtons> </mat-paginator>
<mat-table [dataSource]="dataSource" matSort class="table">
<ng-container class="container" *ngFor="let displayedColumn of displayedColumns" matColumnDef=" displayedColumn ">
<mat-header-cell class="header-cell" *matHeaderCellDef >
<span mat-sort-header class="sort-header"> uppercase </span>
<input class="table-input" matInput (keyup)="applyFilter($event.target.value)" (focus)="setupFilter(displayedColumn)" placeholder="Filter"/>
</mat-header-cell>
<mat-cell class="cell" *matCellDef="let item"> item[displayedColumn] </mat-cell>
</ng-container>
<mat-header-row class="header-row" *matHeaderRowDef="displayedColumns; sticky: true"></mat-header-row>
<mat-row class="row" *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</mat-card>




CSS-Part:



.data 
display: block;
width: 95vw;
overflow: auto;

.table
width: 100vw;
max-width: 100%;
overflow: auto;
margin-bottom: 10px;
display: table;
border-collapse: collapse;
margin: 0px;
background-color: rgb(238, 238, 238);

.row,
.header-row
display: table-row;
min-height: 36px !important;

.cell,
.header-cell
word-wrap: initial;
display: table-cell;
padding: 0px 5px;
line-break: unset;
width: fit-content;
white-space: nowrap;
overflow: hidden;
vertical-align: middle;
text-align: center;

.header-row,
.header-cell
margin: 0 auto;
min-height: 100px !important;
text-align: center;
vertical-align: middle;
align-self: center;

.sort-header
display: flex;
align-content: center;
text-align: center;
justify-content: center;
font-size: 12pt;

.header-cell
font-weight: bold;



.mat-card
min-width: max-content;
max-width: max-content;



If the overflows are both active then I have to scroll down to be able to scroll horizontally but the layout stays as it should. Only the mat-table and the div around it it will be scrolled and the elements above the mat-table (search fields etc.) are staying where they should. Everything stays in the middle of the screen.



If I deactivate the overflow from the div in the ".data" then the normal browser scrollbar appears and I don't have to scroll down anymore. But the mat-table expands the screen to the right on scrolling and the search fields above will stay on the left when scrolling horizontally which for me breaks the layout.



What I need would be a combination of both scrollbars which would be a floating scrollbar in my eyes. I would only scroll the mat-table but the rest stays in place.



Is there a way to accomplish that natively with CSS or Angular?



Demo:
https://stackblitz.com/edit/angular-elm867?file=src%2Fapp%2Fapp.component.scss



If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".



Here's an image on how the table scrollbar should replace the normal scrollbar: enter image description here










share|improve this question



















  • 2





    Please create a stackblitz demo for the problem

    – Abhishek Kumar
    Mar 25 at 9:44











  • stackblitz.com/edit/… If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".

    – suckerp
    Mar 25 at 10:22












  • If this is what you need ? See : stackblitz.com/edit/angular-horizontal-alignment?file=src/app/… , or suggest, i can change accordingly

    – Abhishek Kumar
    Mar 25 at 10:42











  • Thanks. The outer scrollbar should behave like the inner one and only one scrollbar should be visible. The inner scrollbar is the one from ".data". Not sure if the "overflow" from ".table" has an effect. I populated the table with more data to make it clearer. When scrolling horizontally the table data / headers should move left / right and the buttons in this example need to stay always visible. Both happens with "overflow" activated in ".data". But the scrollbar should be at the bottom of the browser and not at the end of the table.

    – suckerp
    Mar 25 at 11:48











  • Also it would be great if the paginator could float along with the scrolling always staying on the right of the actual view.

    – suckerp
    Mar 25 at 11:49













2












2








2








Is it possible to add a floating horizontal scrollbar to a mat-table in Angular 7 without JQuery or any other additional plugins?



I have a mat-table that shows 6 columns but also can dynamically add 100+ columns with the push of a button.
But then the layout breaks.



HTML-Part:



<button (click)="showLess()" mat-stroked-button class="show-button">Show Less</button>
<button (click)="showMore()" mat-stroked-button class="show-button">Show More</button>

<div class="component data component-card">
<mat-card *ngIf="dataSource?.filteredData" class="mat-card">
<mat-paginator [length]="length" [pageSize]="100" [pageSizeOptions]="[100, 250, 500, 1000, 2000]" showFirstLastButtons> </mat-paginator>
<mat-table [dataSource]="dataSource" matSort class="table">
<ng-container class="container" *ngFor="let displayedColumn of displayedColumns" matColumnDef=" displayedColumn ">
<mat-header-cell class="header-cell" *matHeaderCellDef >
<span mat-sort-header class="sort-header"> uppercase </span>
<input class="table-input" matInput (keyup)="applyFilter($event.target.value)" (focus)="setupFilter(displayedColumn)" placeholder="Filter"/>
</mat-header-cell>
<mat-cell class="cell" *matCellDef="let item"> item[displayedColumn] </mat-cell>
</ng-container>
<mat-header-row class="header-row" *matHeaderRowDef="displayedColumns; sticky: true"></mat-header-row>
<mat-row class="row" *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</mat-card>




CSS-Part:



.data 
display: block;
width: 95vw;
overflow: auto;

.table
width: 100vw;
max-width: 100%;
overflow: auto;
margin-bottom: 10px;
display: table;
border-collapse: collapse;
margin: 0px;
background-color: rgb(238, 238, 238);

.row,
.header-row
display: table-row;
min-height: 36px !important;

.cell,
.header-cell
word-wrap: initial;
display: table-cell;
padding: 0px 5px;
line-break: unset;
width: fit-content;
white-space: nowrap;
overflow: hidden;
vertical-align: middle;
text-align: center;

.header-row,
.header-cell
margin: 0 auto;
min-height: 100px !important;
text-align: center;
vertical-align: middle;
align-self: center;

.sort-header
display: flex;
align-content: center;
text-align: center;
justify-content: center;
font-size: 12pt;

.header-cell
font-weight: bold;



.mat-card
min-width: max-content;
max-width: max-content;



If the overflows are both active then I have to scroll down to be able to scroll horizontally but the layout stays as it should. Only the mat-table and the div around it it will be scrolled and the elements above the mat-table (search fields etc.) are staying where they should. Everything stays in the middle of the screen.



If I deactivate the overflow from the div in the ".data" then the normal browser scrollbar appears and I don't have to scroll down anymore. But the mat-table expands the screen to the right on scrolling and the search fields above will stay on the left when scrolling horizontally which for me breaks the layout.



What I need would be a combination of both scrollbars which would be a floating scrollbar in my eyes. I would only scroll the mat-table but the rest stays in place.



Is there a way to accomplish that natively with CSS or Angular?



Demo:
https://stackblitz.com/edit/angular-elm867?file=src%2Fapp%2Fapp.component.scss



If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".



Here's an image on how the table scrollbar should replace the normal scrollbar: enter image description here










share|improve this question
















Is it possible to add a floating horizontal scrollbar to a mat-table in Angular 7 without JQuery or any other additional plugins?



I have a mat-table that shows 6 columns but also can dynamically add 100+ columns with the push of a button.
But then the layout breaks.



HTML-Part:



<button (click)="showLess()" mat-stroked-button class="show-button">Show Less</button>
<button (click)="showMore()" mat-stroked-button class="show-button">Show More</button>

<div class="component data component-card">
<mat-card *ngIf="dataSource?.filteredData" class="mat-card">
<mat-paginator [length]="length" [pageSize]="100" [pageSizeOptions]="[100, 250, 500, 1000, 2000]" showFirstLastButtons> </mat-paginator>
<mat-table [dataSource]="dataSource" matSort class="table">
<ng-container class="container" *ngFor="let displayedColumn of displayedColumns" matColumnDef=" displayedColumn ">
<mat-header-cell class="header-cell" *matHeaderCellDef >
<span mat-sort-header class="sort-header"> uppercase </span>
<input class="table-input" matInput (keyup)="applyFilter($event.target.value)" (focus)="setupFilter(displayedColumn)" placeholder="Filter"/>
</mat-header-cell>
<mat-cell class="cell" *matCellDef="let item"> item[displayedColumn] </mat-cell>
</ng-container>
<mat-header-row class="header-row" *matHeaderRowDef="displayedColumns; sticky: true"></mat-header-row>
<mat-row class="row" *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</mat-card>




CSS-Part:



.data 
display: block;
width: 95vw;
overflow: auto;

.table
width: 100vw;
max-width: 100%;
overflow: auto;
margin-bottom: 10px;
display: table;
border-collapse: collapse;
margin: 0px;
background-color: rgb(238, 238, 238);

.row,
.header-row
display: table-row;
min-height: 36px !important;

.cell,
.header-cell
word-wrap: initial;
display: table-cell;
padding: 0px 5px;
line-break: unset;
width: fit-content;
white-space: nowrap;
overflow: hidden;
vertical-align: middle;
text-align: center;

.header-row,
.header-cell
margin: 0 auto;
min-height: 100px !important;
text-align: center;
vertical-align: middle;
align-self: center;

.sort-header
display: flex;
align-content: center;
text-align: center;
justify-content: center;
font-size: 12pt;

.header-cell
font-weight: bold;



.mat-card
min-width: max-content;
max-width: max-content;



If the overflows are both active then I have to scroll down to be able to scroll horizontally but the layout stays as it should. Only the mat-table and the div around it it will be scrolled and the elements above the mat-table (search fields etc.) are staying where they should. Everything stays in the middle of the screen.



If I deactivate the overflow from the div in the ".data" then the normal browser scrollbar appears and I don't have to scroll down anymore. But the mat-table expands the screen to the right on scrolling and the search fields above will stay on the left when scrolling horizontally which for me breaks the layout.



What I need would be a combination of both scrollbars which would be a floating scrollbar in my eyes. I would only scroll the mat-table but the rest stays in place.



Is there a way to accomplish that natively with CSS or Angular?



Demo:
https://stackblitz.com/edit/angular-elm867?file=src%2Fapp%2Fapp.component.scss



If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".



Here's an image on how the table scrollbar should replace the normal scrollbar: enter image description here







css angular angular-material






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 12:48







suckerp

















asked Mar 25 at 9:41









suckerpsuckerp

557 bronze badges




557 bronze badges







  • 2





    Please create a stackblitz demo for the problem

    – Abhishek Kumar
    Mar 25 at 9:44











  • stackblitz.com/edit/… If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".

    – suckerp
    Mar 25 at 10:22












  • If this is what you need ? See : stackblitz.com/edit/angular-horizontal-alignment?file=src/app/… , or suggest, i can change accordingly

    – Abhishek Kumar
    Mar 25 at 10:42











  • Thanks. The outer scrollbar should behave like the inner one and only one scrollbar should be visible. The inner scrollbar is the one from ".data". Not sure if the "overflow" from ".table" has an effect. I populated the table with more data to make it clearer. When scrolling horizontally the table data / headers should move left / right and the buttons in this example need to stay always visible. Both happens with "overflow" activated in ".data". But the scrollbar should be at the bottom of the browser and not at the end of the table.

    – suckerp
    Mar 25 at 11:48











  • Also it would be great if the paginator could float along with the scrolling always staying on the right of the actual view.

    – suckerp
    Mar 25 at 11:49












  • 2





    Please create a stackblitz demo for the problem

    – Abhishek Kumar
    Mar 25 at 9:44











  • stackblitz.com/edit/… If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".

    – suckerp
    Mar 25 at 10:22












  • If this is what you need ? See : stackblitz.com/edit/angular-horizontal-alignment?file=src/app/… , or suggest, i can change accordingly

    – Abhishek Kumar
    Mar 25 at 10:42











  • Thanks. The outer scrollbar should behave like the inner one and only one scrollbar should be visible. The inner scrollbar is the one from ".data". Not sure if the "overflow" from ".table" has an effect. I populated the table with more data to make it clearer. When scrolling horizontally the table data / headers should move left / right and the buttons in this example need to stay always visible. Both happens with "overflow" activated in ".data". But the scrollbar should be at the bottom of the browser and not at the end of the table.

    – suckerp
    Mar 25 at 11:48











  • Also it would be great if the paginator could float along with the scrolling always staying on the right of the actual view.

    – suckerp
    Mar 25 at 11:49







2




2





Please create a stackblitz demo for the problem

– Abhishek Kumar
Mar 25 at 9:44





Please create a stackblitz demo for the problem

– Abhishek Kumar
Mar 25 at 9:44













stackblitz.com/edit/… If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".

– suckerp
Mar 25 at 10:22






stackblitz.com/edit/… If you click on Show More just see how the buttons behave when scroll after commentating "overflow: auto" in and out in the ".data".

– suckerp
Mar 25 at 10:22














If this is what you need ? See : stackblitz.com/edit/angular-horizontal-alignment?file=src/app/… , or suggest, i can change accordingly

– Abhishek Kumar
Mar 25 at 10:42





If this is what you need ? See : stackblitz.com/edit/angular-horizontal-alignment?file=src/app/… , or suggest, i can change accordingly

– Abhishek Kumar
Mar 25 at 10:42













Thanks. The outer scrollbar should behave like the inner one and only one scrollbar should be visible. The inner scrollbar is the one from ".data". Not sure if the "overflow" from ".table" has an effect. I populated the table with more data to make it clearer. When scrolling horizontally the table data / headers should move left / right and the buttons in this example need to stay always visible. Both happens with "overflow" activated in ".data". But the scrollbar should be at the bottom of the browser and not at the end of the table.

– suckerp
Mar 25 at 11:48





Thanks. The outer scrollbar should behave like the inner one and only one scrollbar should be visible. The inner scrollbar is the one from ".data". Not sure if the "overflow" from ".table" has an effect. I populated the table with more data to make it clearer. When scrolling horizontally the table data / headers should move left / right and the buttons in this example need to stay always visible. Both happens with "overflow" activated in ".data". But the scrollbar should be at the bottom of the browser and not at the end of the table.

– suckerp
Mar 25 at 11:48













Also it would be great if the paginator could float along with the scrolling always staying on the right of the actual view.

– suckerp
Mar 25 at 11:49





Also it would be great if the paginator could float along with the scrolling always staying on the right of the actual view.

– suckerp
Mar 25 at 11:49












2 Answers
2






active

oldest

votes


















0














in your existing stackblitz, Need one change to accomplish this...



In SCSS, define the class as:
mat-paginatorwidth:97vw;






share|improve this answer























  • @suckerp is there anything still unresolved with your question?

    – Akber Iqbal
    Mar 26 at 8:55


















0














Add the following to styles.css to remove the horizontal scroll bar



html,
body
margin: 0 !important;
padding: 0 !important;



Also add to bring horizontal scroll in .table if extra columns are overflowed.



.mat-card 
min-width: 100% !important;
max-width: 100% !important;

.table
display: block !important;



Stackblitz Demo with adjusted table data after dynamic column addition




Update 1 :



Fixed the max-height for the container div .data for fixing the horizontal scroll bar in the container.



.data 
max-height: 500px;
overflow: auto;



Demo with Fixed Max Height on Outer Container for fixing scrolls






share|improve this answer

























  • Unfortunately it's not working the way I meant it to work. For 6 columns it's good, but imagine table with 20, 30, 50 or even more columns and 1.000+ entires then you'd still need to scroll down to get the horizontal scrollbar. I can completely deactivate the normal scrollbar by adding "overflow-x: hidden" to .body, .main in scss. And what needs to happen now is that the scrollbar from the bottom of the table needs to become the new browser scrollbar. It might sound very complicated, I assume. I added additonal columns and data to illustrate this.

    – suckerp
    Mar 25 at 12:46












  • @suckerp i have implemented the scenario, please see this updated stackblitz as a reference to achieve your desired result.

    – Abhishek Kumar
    Mar 26 at 5:43













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334935%2ffloating-horizontal-scrollbar-with-mat-table-in-angular%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














in your existing stackblitz, Need one change to accomplish this...



In SCSS, define the class as:
mat-paginatorwidth:97vw;






share|improve this answer























  • @suckerp is there anything still unresolved with your question?

    – Akber Iqbal
    Mar 26 at 8:55















0














in your existing stackblitz, Need one change to accomplish this...



In SCSS, define the class as:
mat-paginatorwidth:97vw;






share|improve this answer























  • @suckerp is there anything still unresolved with your question?

    – Akber Iqbal
    Mar 26 at 8:55













0












0








0







in your existing stackblitz, Need one change to accomplish this...



In SCSS, define the class as:
mat-paginatorwidth:97vw;






share|improve this answer













in your existing stackblitz, Need one change to accomplish this...



In SCSS, define the class as:
mat-paginatorwidth:97vw;







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 10:32









Akber IqbalAkber Iqbal

4,7256 gold badges16 silver badges32 bronze badges




4,7256 gold badges16 silver badges32 bronze badges












  • @suckerp is there anything still unresolved with your question?

    – Akber Iqbal
    Mar 26 at 8:55

















  • @suckerp is there anything still unresolved with your question?

    – Akber Iqbal
    Mar 26 at 8:55
















@suckerp is there anything still unresolved with your question?

– Akber Iqbal
Mar 26 at 8:55





@suckerp is there anything still unresolved with your question?

– Akber Iqbal
Mar 26 at 8:55













0














Add the following to styles.css to remove the horizontal scroll bar



html,
body
margin: 0 !important;
padding: 0 !important;



Also add to bring horizontal scroll in .table if extra columns are overflowed.



.mat-card 
min-width: 100% !important;
max-width: 100% !important;

.table
display: block !important;



Stackblitz Demo with adjusted table data after dynamic column addition




Update 1 :



Fixed the max-height for the container div .data for fixing the horizontal scroll bar in the container.



.data 
max-height: 500px;
overflow: auto;



Demo with Fixed Max Height on Outer Container for fixing scrolls






share|improve this answer

























  • Unfortunately it's not working the way I meant it to work. For 6 columns it's good, but imagine table with 20, 30, 50 or even more columns and 1.000+ entires then you'd still need to scroll down to get the horizontal scrollbar. I can completely deactivate the normal scrollbar by adding "overflow-x: hidden" to .body, .main in scss. And what needs to happen now is that the scrollbar from the bottom of the table needs to become the new browser scrollbar. It might sound very complicated, I assume. I added additonal columns and data to illustrate this.

    – suckerp
    Mar 25 at 12:46












  • @suckerp i have implemented the scenario, please see this updated stackblitz as a reference to achieve your desired result.

    – Abhishek Kumar
    Mar 26 at 5:43















0














Add the following to styles.css to remove the horizontal scroll bar



html,
body
margin: 0 !important;
padding: 0 !important;



Also add to bring horizontal scroll in .table if extra columns are overflowed.



.mat-card 
min-width: 100% !important;
max-width: 100% !important;

.table
display: block !important;



Stackblitz Demo with adjusted table data after dynamic column addition




Update 1 :



Fixed the max-height for the container div .data for fixing the horizontal scroll bar in the container.



.data 
max-height: 500px;
overflow: auto;



Demo with Fixed Max Height on Outer Container for fixing scrolls






share|improve this answer

























  • Unfortunately it's not working the way I meant it to work. For 6 columns it's good, but imagine table with 20, 30, 50 or even more columns and 1.000+ entires then you'd still need to scroll down to get the horizontal scrollbar. I can completely deactivate the normal scrollbar by adding "overflow-x: hidden" to .body, .main in scss. And what needs to happen now is that the scrollbar from the bottom of the table needs to become the new browser scrollbar. It might sound very complicated, I assume. I added additonal columns and data to illustrate this.

    – suckerp
    Mar 25 at 12:46












  • @suckerp i have implemented the scenario, please see this updated stackblitz as a reference to achieve your desired result.

    – Abhishek Kumar
    Mar 26 at 5:43













0












0








0







Add the following to styles.css to remove the horizontal scroll bar



html,
body
margin: 0 !important;
padding: 0 !important;



Also add to bring horizontal scroll in .table if extra columns are overflowed.



.mat-card 
min-width: 100% !important;
max-width: 100% !important;

.table
display: block !important;



Stackblitz Demo with adjusted table data after dynamic column addition




Update 1 :



Fixed the max-height for the container div .data for fixing the horizontal scroll bar in the container.



.data 
max-height: 500px;
overflow: auto;



Demo with Fixed Max Height on Outer Container for fixing scrolls






share|improve this answer















Add the following to styles.css to remove the horizontal scroll bar



html,
body
margin: 0 !important;
padding: 0 !important;



Also add to bring horizontal scroll in .table if extra columns are overflowed.



.mat-card 
min-width: 100% !important;
max-width: 100% !important;

.table
display: block !important;



Stackblitz Demo with adjusted table data after dynamic column addition




Update 1 :



Fixed the max-height for the container div .data for fixing the horizontal scroll bar in the container.



.data 
max-height: 500px;
overflow: auto;



Demo with Fixed Max Height on Outer Container for fixing scrolls







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 26 at 5:41

























answered Mar 25 at 11:58









Abhishek KumarAbhishek Kumar

1,5934 silver badges18 bronze badges




1,5934 silver badges18 bronze badges












  • Unfortunately it's not working the way I meant it to work. For 6 columns it's good, but imagine table with 20, 30, 50 or even more columns and 1.000+ entires then you'd still need to scroll down to get the horizontal scrollbar. I can completely deactivate the normal scrollbar by adding "overflow-x: hidden" to .body, .main in scss. And what needs to happen now is that the scrollbar from the bottom of the table needs to become the new browser scrollbar. It might sound very complicated, I assume. I added additonal columns and data to illustrate this.

    – suckerp
    Mar 25 at 12:46












  • @suckerp i have implemented the scenario, please see this updated stackblitz as a reference to achieve your desired result.

    – Abhishek Kumar
    Mar 26 at 5:43

















  • Unfortunately it's not working the way I meant it to work. For 6 columns it's good, but imagine table with 20, 30, 50 or even more columns and 1.000+ entires then you'd still need to scroll down to get the horizontal scrollbar. I can completely deactivate the normal scrollbar by adding "overflow-x: hidden" to .body, .main in scss. And what needs to happen now is that the scrollbar from the bottom of the table needs to become the new browser scrollbar. It might sound very complicated, I assume. I added additonal columns and data to illustrate this.

    – suckerp
    Mar 25 at 12:46












  • @suckerp i have implemented the scenario, please see this updated stackblitz as a reference to achieve your desired result.

    – Abhishek Kumar
    Mar 26 at 5:43
















Unfortunately it's not working the way I meant it to work. For 6 columns it's good, but imagine table with 20, 30, 50 or even more columns and 1.000+ entires then you'd still need to scroll down to get the horizontal scrollbar. I can completely deactivate the normal scrollbar by adding "overflow-x: hidden" to .body, .main in scss. And what needs to happen now is that the scrollbar from the bottom of the table needs to become the new browser scrollbar. It might sound very complicated, I assume. I added additonal columns and data to illustrate this.

– suckerp
Mar 25 at 12:46






Unfortunately it's not working the way I meant it to work. For 6 columns it's good, but imagine table with 20, 30, 50 or even more columns and 1.000+ entires then you'd still need to scroll down to get the horizontal scrollbar. I can completely deactivate the normal scrollbar by adding "overflow-x: hidden" to .body, .main in scss. And what needs to happen now is that the scrollbar from the bottom of the table needs to become the new browser scrollbar. It might sound very complicated, I assume. I added additonal columns and data to illustrate this.

– suckerp
Mar 25 at 12:46














@suckerp i have implemented the scenario, please see this updated stackblitz as a reference to achieve your desired result.

– Abhishek Kumar
Mar 26 at 5:43





@suckerp i have implemented the scenario, please see this updated stackblitz as a reference to achieve your desired result.

– Abhishek Kumar
Mar 26 at 5:43

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334935%2ffloating-horizontal-scrollbar-with-mat-table-in-angular%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript