I have a primeng VirtualScroller and it has a property scrollHeight that fixes some height. I've tried to set 100% at value but it doesn't accept. Also tried to add style or class to component to set height 100% but does not work aswell. How can I make the height have same height of the browser window?
<p-virtualScroller [value]="lazyCars" scrollHeight="40em" [itemSize]="150" [rows]="50" [cache]="false"
[lazy]="true" (onLazyLoad)="loadCarsLazy($event)" [totalRecords]="totalLazyCarsLength">
<ng-template let-car pTemplate="item" let-i="index">
<div class="ui-g car-item mt-1">
<div class="ui-g-12 ui-md-2">
<div class="ui-g-12 ui-md-12" style="font-size: 11px; text-align: center; padding-top: 18px">{{ generateDate() | date: 'dd/MM/yyyy' }}</div>
<div class="ui-g-12 ui-md-12" style="font-size: 24px; text-align: center; padding-top: 18px">{{ generateDate() | date: 'HH:mm:ss' }}</div>
</div>
<div class="ui-g-12 ui-md-2" style="display: flex">
<img class="rounded-image" src="../../assets/images/profileplaceholder.jpg" width="115" height="100" />
<!--<i style="font-size: 5rem; align-self: center;" class="pi pi-users mx-auto"></i>-->
</div>
<div class="arrow-left"></div>
<div class="ui-g-12 ui-md-5 chat-window">
<div class="ui-g">
<div class="ui-g-10 ui-sm-6">Autor: {{car?.autor}}</div>
<h2 class="ui-g-10 ui-sm-6 ml-2">Evento: {{car?.evento}}</h2>
</div>
</div>
</div>
</ng-template>
<ng-template let-car pTemplate="loadingItem">
<div class="ui-g car-item empty-car-item">
<div class="ui-g-12 ui-md-2">
<div class="empty-car-item-index"></div>
</div>
<div class="ui-g-12 ui-md-2">
<div class="empty-car-item-image"></div>
</div>
<div class="ui-g-12 ui-md-8">
<div class="ui-g">
<div class="ui-g-12"><div class="empty-car-item-text"></div></div>
<div class="ui-g-12"><div class="empty-car-item-text"></div></div>
<div class="ui-g-12"><div class="empty-car-item-text"></div></div>
<div class="ui-g-12"><div class="empty-car-item-text"></div></div>
</div>
</div>
</div>
</ng-template>
</p-virtualScroller>
This can be done using nested flexboxes. I've explained how those work with Angular in a different question. Applying that solution to this problem involves applying the equivalent of the flexbox-middle class to each element that composes the virtual scrolling area:
p-virtualScroller,
/deep/ .ui-virtualscroller,
/deep/ .ui-virtualscroller-content,
/deep/ .ui-virtualscroller-list,
/deep/ cdk-virtual-scroll-viewport {
display : flex;
flex : 1;
flex-direction : column;
}
With that styling, the scrollHeight attribute of the p-virtualScroller element should no longer be set as the component will flex to the height of the parent element:
<p-virtualScroller [itemSize]="50" [value]="items">
<ng-template pTemplate="item" let-obj>
{{ obj.name }}
</ng-template>
</p-virtualScroller>
The full code and a demo of the working result is available here.
Related
I want both Components the same height (the size of left form) tried margin , padding nothing works
below is the code for its parent element HTML
<mat-tab label="Update Profile">
<div class="container">
<mat-card class="mat-card-container">
<div class="vertical-center row" >
<div class="col-lg-1">
</div>
<div class="col-lg-6">
<app-register [user]="user"></app-register>
</div>
<div class="col-lg-4 password-change-form">
<app-password-change [id]="user.id"></app-password-change>
</div>
<div class="col-lg-1">
</div>
</div>
</mat-card>
</div>
</mat-tab>
CSS
.vertical-center {
margin-top: 2rem;
margin-bottom: 1rem;
display: flex;
align-items: center;
}
.password-change-form{
padding: inherit;
}
.spacer{}
Better you can use flex layout. Refer: [https://github.com/angular/flex-layout/wiki/fxLayoutAlign-API][1]
Set fxFlexAlign="stretch" to have all mat-card in same height.
The problem is not with the mat card, but with the div with password-change-form if you were asking to make them the same height:
.password-change-form{
height:100%
}
but if you want them to have the same width, you should probably add col-lg-5 to both of them instead of 6 and 4
<div class="col-lg-5">
<app-register [user]="user"></app-register>
</div>
<div class="col-lg-5 password-change-form">
<app-password-change [id]="user.id"></app-password-change>
</div>
I'm trying to find a solution how to vertically align the 2 rows in the footer which are placed with a Bootstrap grid.
I've already tried to make a wrapper for the content and apply the regular flexbox solution:
display: flex; align-items: center. But this moves both rows to be on the same row.
Fiddle here https://codepen.io/pen/WNNPdxv
HTML
<footer class="footer">
<div class="footer-wrapper">
<div class="container">
<div class="row row">
<div class="col-sm-8 footer-credit">
<h6>GetMove</h6>
<p>Copyright © 2019 GetMove All Rights Reserved</p>
</div>
<div class="col-sm-2 footer-contact">
<h6>Contact</h6>
hola#getmove.net
</div>
<div class="col-sm-2 footer-social-icons">
<h6>Follow us</h6>
<a class="social-icon" target="_blank" href="https://www.facebook.com/pg/GetMove.Official/"
><i class="fab fa-facebook-square"></i
></a>
<a class="social-icon" target="_blank" href="https://www.instagram.com/getmovemx/"
><i class="fab fa-instagram"></i
></a>
<a class="social-icon" target="_blank" href="https://soundcloud.com/getmove"
><i class="fab fa-soundcloud"></i
></a>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-8 text-center"></div>
<div class="col-sm-4 footer-newsletter">
<h6>Subscribe</h6>
<div class="input-group input-group-sm mb-3">
<input
type="text"
class="form-control shadow-none"
id="subscribe"
placeholder="# Enter your email adress"
aria-label="Sizing example input"
aria-describedby="inputGroup-sizing-sm"
/>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="button-addon1">
Submit
</button>
</div>
</div>
</div>
</div>
</div>
<div class="container footer-credit">
<div class="row">
<div class="col-sm-8"></div>
<div class="col-sm-4 footer-credit"></div>
</div>
</div>
</div>
</footer>
CSS
.footer {
width: 100%;
height: 24em; /* Set the fixed height of the footer here */
background-color: #f4f2f0;
margin-top: 4em;
}
.footer-social-icons {
list-style-type: none;
}
.footer h6 {
text-transform: uppercase;
font-size: 16px;
}
.footer-credit {
font-size: 11px;
}
.social-icon {
/* display: block; */
margin: 0;
font-size: 16px;
}
.form-control:focus {
border-color: black;
}
The idea of a wrapper to vertically center content is correct, however you already have a wrapper in place => container.
No need to have multiple containers inside a single section (footer). You use rows for this.
So to clean-up your structure a bit, as suggested in the comments, is key to understand what's going on.
container is your wrapper
row row is redundant
empty columns as placeholder are not required with flexbox (bootstrap 4), not sure if that's what's going on... => m-auto, ml-auto, mr-auto
place custom classes inside columns (these blocks might change places someday, especially when designing for a CMS)
keep the structure clean and decorate with utility classes if needed (padding, margin, ...)
HTML Structure
<footer role="contentinfo">
<div class="container">
<div class="row">
<div class="col-sm-7"></div>
<div class="col-sm-3"></div>
<div class="col-sm-2"></div>
</div>
<div class="row">
<div class="col-sm-5 ml-auto"></div>
</div>
<div class="row">
<div class="col-sm-5 ml-auto"></div>
</div>
</div>
</footer>
Solution
Now your height is set on the footer, your container is simply taking the required height inside the space. This means you should now be able to move it vertically with flexbox.
footer[role="contentinfo"] {
display: flex;
flex-flow: column wrap;
justify-content: center; /* content of the footer is the container */
}
DEMO
im trying to postion items to be in the center of the div but it doesn't work
this is a picture for desired output
i don't know why the div items are going to left and the input text don't take the full length of the div
im also trying to add space between the text and the gear icon of the orange buttons
and this is my code :
<af:dialog contentWidth="400" type="none" id="aaa" modal="true">
<div class="row">
<div class="col-md-8 sm-b-b">
<div class="sm-padding-5">
<af:inputText inlineStyle="display: inline-block;width:100%" value="sohoooooooooooooooooo"
simple="true" id="it1"/>
</div>
</div>
<div class="col-md-4 sm-b-b">
<div class="sm-padding-5">
<af:button inlineStyle="display: inline-block;width:100%" text="Search" id="b1"></af:button>
</div>
</div>
</div>
<af:forEach var="node" items="#{bindings.ViewObj11.collectionModel}">
<div class="row">
<div class="col-md-12 sm-b-b">
<div class="sm-padding-5">
<af:link text="#{bindings.Value1.inputValue}" styleClass="btn btn-primary white" id="ot1">
<span aria-hidden="true" class="fa fa-gear"></span>
</af:link>
</div>
</div>
</div>
</af:forEach>
Try this Style in your style sheet
.sm-b-b{
margin: 0 auto;
text-align: center;
width: 100%;
}
My website has a menubar which is in the main component html and inside this html is also the app-selector of another component:
MainComponent.html
<div style="height:200px">This is my Menubar</div>
<app-test></app-test>
I would like to display 3 boxes in my testComponent.html.
I am using flexLayout: https://github.com/angular/flex-layout
<div fxLayout="column" fxLayoutAlign="space-between none" style="height: 100%">
<div style="background-color: red">
T1
</div>
<div style="background-color: blue">
T2
</div>
<div style="background-color: yellow; height: 200px">
T3
</div>
</div>
The problem is that because there is a menubar, i get a scrolling behaviour but I just want the last box to end at my screen bottom. See here: http://prntscr.com/nhwcbp
How can I achieve this?
https://stackblitz.com/edit/flex-layout-angular-material-xssepa
put below style in style.css:
html, body { height: 100%; width: 100%; margin: 0; }
Remove height: 100vh and make use of flexbox
<div fxLayout="column" style="height:100%">
<div fxLayout="row" fxLayoutAlign="center">
<mat-card fxFlex="50">
<div fxLayout="row">
<div fxFlex="30" class="action-blurb">This is a blurb.</div>
<div fxFlex="30" class="action-blurb" fxFlexOffset="5">This is a blurb.</div>
<div fxFlex="30" class="action-blurb" fxFlexOffset="5">This is a blurb.</div>
</div>
</mat-card>
</div>
<div fxFlex="">
<app-test></app-test>
</div>
</div>
I hope this should do the trick as per this demo
I want is that these circles to be center aligned , I tried using some display inline block but no affect on it and some other properties that make center align but i failed picture of those circles
I am searching for this already the whole day :s
How can help me on this one?
Your help would be much appreciated.
Thank you
.menu{
width:70px;
height:70px;
border-radius:50px;
font-size:20px;
color:green;
line-height:100px;
background:#32C947;
overflow: hidden;
list-style-type: none;
margin-left: auto;
margin-right: auto;
display: table-cell;
vertical-align: middle;
}
.menu:hover{
color:#ccc;
text-decoration:none;
background:#333
}
<div class = "container">
<div class="row ">
<div class="col-md-12 ">
<h1 class = "_font ">All Plans Include</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Hello</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
</div>
</div>
To the parent div of a circle you have to give some width property and use
this and margin: 0 auto;. I hope this will works.
In your code parent div .col-md-1 .so you have to create one more div and
apply above property.
<div class="col-md-1 ">
<div class="circle_menu">
</div>
<h1 class="_circle">Google Analytic</h1>
</div>
.menu{
width:70px;
height:70px;
border-radius:50px;
font-size:20px;
color:green;
line-height:100px;
background:#32C947;
display: block;
overflow: hidden;
list-style-type: none;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
}
.center{
text-align: center;
}
.menu:hover{
color:#ccc;
text-decoration:none;
background:#333
}
<div class = "container">
<div class="row justify-content-center">
<div class="col-md-12 center">
<h1 class = "_font ">All Plans Include</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Hello</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
</div>
</div>
The col-md-1 class is probably from bootstrap and therefor floating to the left. You could add the col-md-offset class to push the menu items to the center.
There are several ways to center align that block. But since you use the Bootstrap it will be best to use the in build display:block property of a center-block class.
Set an element to display: block and center via margin. Available as a
mixin and class.
Read More from Here Bootstrap Documentation About centering a Class
You can do either any one of this
<div class = "container center-block">
<div class="row ">
CODE SNIPPPET
</div>
</div>
OR
<div class = "container">
<div class="row center-block">
CODE SNIPPPET
</div>
</div>
The center-block class which we add overrides the display:block put in by using the regular container or row class
Hope This helped. Happy Coding. :)
Do you have Bootstrap actually linked to your code? I just put it into a CodePen
and linked Bootstrap3 and it formatted correctly as you want (except the text is to big). I took out these lines from your .menu class as well:
vertical-align: middle;
list-style-type: none;
margin-left: auto;
margin-right: auto;
Edit:
So the reason why your circles are not centered is because you are using Bootstrap's grid system. The grid is sliced into 12 different sections and you have 8 of the sections filled with elements (and 12 isn't divided by 8 evenly). That means that there are 4 spaces not being used to the right of your circles.
To fix this, I added two empty div tags before all of the elements you have implemented like so:
<div class="col-md-1"></div>
This makes it so that there are two empty grid slots before your circles (to the left) and two after (to the right). Here is the Updated CodePen for you to look at.
Note: I added this style for you to center your text through CSS:
div.row {
text-align: center;
}