How to make md Content scrollable in Angular material Design - html

I am using ui-view in md-content to display a list but its getting overflow i want list in md-content should be scrollable
here is my index.html
<div layout-lt-lg="row" class="screen-bg">
<div flex-lt-lg="100">
<!--header-->
<md-toolbar class="app-bar-bg" style="background-color: #9013fe;">
<div class="status-bar-bg"></div>
<div class="md-toolbar-tools">
<md-button class="md-icon-button" aria-label="Settings">
<!--<md-icon md-svg-icon="app/images/back1.svg"></md-icon>-->
</md-button>
<h2>
<span></span>
</h2>
<span flex=""></span>
<md-button class="md-icon-button" aria-label="Favorite">
<!--<md-icon md-svg-icon="app/images/a.svg"></md-icon>-->
</md-button>
</div>
</md-toolbar>
<!--content-->
<div>
<md-content>
<ui-view></ui-view>
</md-content>
</div>
</div>
</div>
here is my template
<md-list flex>
<md-list-item class="md-3-line" ng-repeat="broadCast in broadCasts">
<div class="md-list-item-text" layout="column" >
<h3>{{broadCast.name}}</h3>
<h3>{{broadCast.phone}}</h3>
</div>
</md-list-item>
</md-list>

To make the list scrollable:
Add a class to md-list.
<md-list class="make-scrollable" flex>
<md-list-item class="md-3-line" ng-repeat="broadCast in broadCasts">
<div class="md-list-item-text" layout="column">
<h3>{{broadCast.name}}</h3>
<h3>{{broadCast.phone}}</h3>
</div>
</md-list-item>
</md-list>
Style the md-list in your css file like so:
md-list.make-scrollable {
height: 600px; //Or any other height you wish
overflow-y: scroll;
}
That should make the overflowing content scrollable

You are using too many unnecessary container elements.
<div layout-lt-lg="row" flex-lt-lg="100" class="screen-bg">
<!--header-->
<md-toolbar class="app-bar-bg" style="background-color: #9013fe;">
<div class="status-bar-bg"></div> //desired controller buttons
<div class="md-toolbar-tools"></div> //desired controller buttons
</md-toolbar>
<!--content-->
<md-content flex ui-view>
</md-content>
</div>
Here is a working example. There are some changes but basic structure is almost same.

Related

Why is the div wider than its content?

I'm trying to create a page with a 20-60-20 flex fill layout but the div in the center which should make up 60% of the page is wider than its content so it makes its content look like it is off-center.
home.component.html:
<div fxLayout="row wrap" fxLayoutGap="20px grid">
<div *ngFor="let data of DUMMY_DATA">
<mat-card class="example-card" >
<img mat-card-image src="https://material.angular.io/assets/img/examples/shiba2.jpg" alt="Photo of a Shiba Inu">
<mat-card-content class="description-max-height">
<p>
{{data.description.length > 100 ? data.description.substring(0, 100) + '...' : data.description}}
</p>
</mat-card-content>
<mat-card-actions>
<button mat-button>LIKE</button>
<button mat-button>SHARE</button>
</mat-card-actions>
</mat-card>
</div>
</div>
home.component.css:
.example-card {
width: 250px;
height: 300px;
}
.description-max-height {
max-height: 30px;
}
app.component.html:
<mat-toolbar color="primary" style="margin-bottom: 20px">
<mat-toolbar-row>
<span>Some title</span>
<span class="toolbar-spacer"></span>
<button mat-button color="accent" (click)="openLoginDialog()">Log In</button>
<button mat-button color="accent" (click)="openSignupDialog()">Register</button>
</mat-toolbar-row>
</mat-toolbar>
<div fxLayout="row">
<div fxFlex="20"></div>
<router-outlet fxFlex="60"></router-outlet>
<div fxFlex="20"></div>
</div>
app.compoenent.css:
.toolbar-spacer {
flex: 1 1 auto;
}
How can I implement this so that will display the home.component.html on the center of the page without it being wider than it's contet?
You can find a Stackblitz example here
The router-outlet isn't a container. All the content routed to a router-outlet is rendered as a sibling node, not as an outlet's child node. So you should wrap the router-outlet with a 60%-width div.
Stackblitz demo
<div fxLayout="row">
<div fxFlex="20"></div>
<div fxFlex="60">
<router-outlet></router-outlet>
</div>
<div fxFlex="20"></div>
</div>
Adding fxLayoutAlign="centre" to the fxLayout div(top level div) in home-component.html should align the items/cards in centre in the container.
<div fxLayout="row wrap" fxLayoutGap="20px grid" fxLayoutAlign="center">

align image to left in angularjs html

You can see rows in picture.
This is code of that view:
<div layout="row" layout-align="space-around center" >
<product-image-thumbnail layout="row" layout-align="left center"
src="vm.callFunction(field)"
setter="vm.callFunction(value)" />
<md-button ng-click="vm.onMouseOver(field.getSrc))" layout="row" layout-align="right center">
<md-icon>zoom_in</md-icon>
</md-button>
</div>
I want to align image or uploadanimage to left, zoom button to right.
But it doesnot work.
i also tried
layout-align="start start
layout-align="end end"
but it did not do the job.
Also i tried buttons to convert to column but it is same.
it makes two rows if i dont put first layout. i need them inside a row.
this is where src image comes
<div ng-show="!vm.src" layout="row">
<md-button class="md-button md-ink-ripple" ng-click="vm.Dialog($event)">
<md-icon>file_upload</md-icon>
<span translate>upload_image</span>
</md-button>
</div>
<div ng-show="vm.src" class="thumbnail" layout="column" layout-align="center center" flex layout-padding ng-click="vm.Dialog($event)">
<img src="{{vm.src}}" style="max-height: 60px;max-width: 60px"
error-src="content/images/no_image_icon.gif"
/>
</div>
<p>This is some text. <img src="smiley.gif" alt="Smiley face" width="42" height="42" align="left"> This is some text.</p>
If you want to use angular material, try using the space-between param. Example Plunker.
<div><!-- shouldn't need layout here-->
<img layout="row" layout-align="space-between center" />
<button layout="row" layout-align="space-between center">Zoom</button>
</div>
You can try this way,
<section layout="row" layout-align="end center" layout-wrap>
<div layout="row" layout-align="start center" flex>
<img src="https://echtemaaltijd.blob.core.windows.net/image/image_671ed3d3-0c1e-43d5-9e9a-86247556fd00" class="md-card-image" alt="Washed Out">
<span flex></span>
</div>
<md-button class="md-warn">Type</md-button>
</section>
DEMO
Try this with flex!
<div layout="row" layout-alignment="stretch">
<product-image-thumbnail flex
src="vm.callFunction(field)"
setter="vm.callFunction(value)" />
<md-button ng-click="vm.onMouseOver(field.getSrc))" flex="5">
<md-icon>zoom_in</md-icon>
</md-button>
</div>
The flex Will take up as much space as it can till 95% of the available width and flex=5 will ensure it is 5$

Angular - Matierial Layout - how to set an image 50% of height of its parent (row-layout)

I am in trouble with angular material layout..
Got this:
this one is just to show the whole html
<div id="MainLayout" layout="column" flex style="height: 100%; overflow: hidden">
<div id="pageHeader" layout="row">
<div layout="column" flex>
<div layout="row" flex>
<img ng-repeat="icon in main.social" class="social" src="{{icon.path}}"/>
</div>
<div layout="row" flex></div>
</div>
</div>
it is about this block:
<div id="LogoDisplay" layout="row" flex="50" ng-style="main.styles.text" style="background: #F9F9F9">
<div layout="column" layout-align="center center" flex fill>
<div id="LogoImage" layout="row" layout-align="center center"><img src="assets/images/user-foto-logo.png" style="???"></div>
<div id="LogoTitle" layout="row" layout-align="center end">User Name</div>
<div id="LogoText" layout="row" layout-align="center start">Job Title</div>
</div>
</div>
and least I got this
<div id="ImageDisplay" flex="50" layout="row" layout-align="center center">
<div ng-repeat="icon in main.icons">{{icon}}</div>
</div>
<div id="pageInfo" layout="row" style="background: #123; color: #FFFF88;">some info footage</div>
I marked the code with ???
There is my problem, got 4 rows, row #1 gots some icons and #4 is just text...
row 2 contains a logo and two rows of text
row 3 contains a couple of logos
My Problem: I would like to have rows 2 and 3 filling 50% of the height. the logo should take 50% of row 2 and the both texts should fit to width of the logo...

Center a div with flex = 33

Thank you for taking a look at my question. I have a div that is expanding across the page horizontally, which is what I want. I have 4 buttons in the div and I am using:
<div layout="row" layout-align="space-around center" layout-sm="column" layout-fill layout-wrap >
Which is good. However, it is taking up the whole div so the buttons look awkwardly spaced out. So I added flex="33" and now they are spaced out, but stuck in using only a third of the page which is what I want and it looks good. The issue I have is it is taking up the first third and I want it to use up the second third of the page. Is there a way to do this with out creating unnecessary divs to occupy the first third?
Here is the complete code:
<div flex="33" layout="row" layout-align="space-around center" layout-sm="column" layout-fill layout-wrap class="pageNavButtons">
<div ng-repeat="button in navPage" layout="column" layout-align="center center" style="color: #ffffff">
<label>{{button.div}}</label>
<span></span>
<md-icon md-svg-src="{{button.icon}}"></md-icon>
</div>
</div>
I do not have any CSS with it yet.
Images:
Before flex=33
After adding it:
You can achieve that by either using flex-offset="33" or by adding layout-align="center" layout="row"on the parent. I would probably use the second one.
<div div layout="row" flex-offset="33">
<div flex="33" layout="row" layout-align="space-around center" layout-sm="column" layout-fill layout-wrap class="pageNavButtons">
<div ng-repeat="button in navPage" layout="column" layout-align="center center" style="color: #ffffff">
<label> {{button.div}}</label>
<span>----- </span>
<md-icon md-svg-src ={{button.icon}}></md-icon>
</div>
</div>
</div>
or
<div layout="row" layout-align="center">
<div flex="33" layout="row" layout-align="space-around center" layout-sm="column" layout-fill layout-wrap class="pageNavButtons">
<div ng-repeat="button in navPage" layout="column" layout-align="center center" style="color: #ffffff">
<label> {{button.div}}</label>
<span>----- </span>
<md-icon md-svg-src ={{button.icon}}></md-icon>
</div>
</div>
</div>
http://codepen.io/kuhnroyal/pen/mPVdRK

scroll table content and fix the rest of the page

I'm using angular + angular material, but I think this question is more general. I have a sidenav to the left and in all the right I display a table with many rows, the problem is that if I try to scroll the table actually the whole page is scrolling, moving the sidenav as well. What I want is to scroll only the table and the rest to be fixed. I spent a lot of time but can't arrive to a solution.
thanks
This is the code, if you are not familiar with angular material, md-content as far as I know should be the same as a div element. layout="row" means that the children of this element should be positioned as a row.
<link rel="stylesheet" href="main/main.css">
<md-content layout="row">
<md-content>
<md-sidenav style="height: 100%" class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="true">
<md-toolbar style="min-height: 1px; height: 50px" class="md-theme-indigo">
<h3 class="md-toolbar-tools">Your Library</h3>
</md-toolbar>
<md-content layout="column" layout-padding flex>
<md-list>
<md-list-item class="md-1-line">
<md-button class="md-primary md-hue-1" ng-click="showSongs()">Songs</md-button>
</md-list-item>
<md-list-item class="md-1-line">
<md-button class="md-primary md-hue-1" ng-click="getArtists()">Artists</md-button>
</md-list-item>
<md-list-item class="md-1-line">
<md-button class="md-primary md-hue-1" ng-click="getAlbums()">Albums</md-button>
</md-list-item>
<md-list-item class="md-1-line">
<md-button class="md-primary md-hue-1">Playlists</md-button>
</md-list-item>
<md-divider ></md-divider>
<md-list-item class="md-1-line">
<md-button class="md-primary md-hue-1">Upload</md-button>
</md-list-item>
<md-list-item class="md-1-line">
<md-button class="md-primary md-hue-1">Download</md-button>
</md-list-item>
</md-list>
</md-content>
</md-sidenav>
</md-content>
<md-content layout="column" layout-padding flex>
<md-content ng-show="showSongsList">
<div ng-include="'main/songsList.html'"></div>
</md-content>
<md-content ng-show="showArtists">
<div ng-include="artistsTemplate.url"></div>
</md-content>
<md-content ng-show="showAlbums">
<div ng-include="albumsTemplate.url"></div>
</md-content>
</md-content>
</md-content>
<md-content ng-include="'navBar.html'"></md-content>
<md-content ng-include="'navBarBottom.html'"></md-content>
Basically the behaviour I'm looking for is something like this: http://codepen.io/zavoloklom/pen/dIgco selecting "Stacked on the left" in sidebar position dropdown, but this example is not for the library I'm using.
Well this might be the solution to your problem
the red div, consider it as your nav; which would be fixed
the green one could be the images div
.left {
float: left;
width: 100px;
height: 100vh;
background-color: red;
word-wrap: break-word;
position:fixed;
}
.right {
width: 300px;
float: right;
height: 300vh;
word-wrap: break-word;
background-color: green;
}
<div class="left">laksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnl</div>
<div class="right">,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas,sdfnlaksndklas</div>