I am using Angular Material and Angular Flex-Layout in my Angular application and I have a problem on displaying the texts on mobile devices. As you can see on small scree, the labels there are cut. How would i display it not being cut or I think the other column should stack below if on mobile devices?
Check this pic below for the current output. Also is there an efficient way to iterate labels and values without to put many divs in html?
HTML
<mat-card-content fxLayout="row" fxLayoutAlign="stretch">
<mat-grid-list cols="6" rowHeight="28px">
<mat-grid-tile [colspan]="1" [rowspan]="4">
<div>
<div class="details" *ngFor="let label of labels">
<label><strong>{{ label.name }}</strong></label>
</div>
</div>
</mat-grid-tile>
<mat-grid-tile [colspan]="2" [rowspan]="4">
<div>
<div class="details">
<label>1</label>
</div>
<div class="details">
<label>Robert Williams</label>
</div>
<div class="details">
<label>robert#gmail.com</label>
</div>
<div class="details">
<label>Human Resource</label>
</div>
</div>
</mat-grid-tile>
<mat-grid-tile [colspan]="1" [rowspan]="4">
<div>
<div class="details" *ngFor="let label of labels2">
<label><strong>{{ label.name }}</strong></label>
</div>
</div>
</mat-grid-tile>
<mat-grid-tile [colspan]="2" [rowspan]="4">
<div>
<div class="details">
<label>9178384567</label>
</div>
<div class="details">
<label>Phoenix</label>
</div>
<div class="details">
<label>Male</label>
</div>
<div class="details">
<label>Aug 21, 2019</label>
</div>
</div>
</mat-grid-tile>
</mat-grid-list>
</mat-card-content>
Here is a fully responsive solution;
<mat-card-content fxLayout="row" fxLayout.xs="column" fxLayoutAlign="start stretch">
<div fxLayout="row">
<div fxLayout="column" fxFlex.xs="50%">
<div fxFlex="25%" class="details" *ngFor="let label of labels">
<label><strong>{{ label }}</strong></label>
</div>
</div>
<div fxLayout="column" fxFlex.xs="50%">
<div fxFlex="25%" class="details">
<label>1</label>
</div>
<div fxFlex="25%" class="details">
<label>Robert Williams</label>
</div>
<div fxFlex="25%" class="details">
<label>robert#gmail.com</label>
</div>
<div fxFlex="25%" class="details">
<label>Human Resource</label>
</div>
</div>
</div>
<div fxLayout="row">
<div fxLayout="column" fxFlex.xs="50%">
<div fxFlex="25%" class="details" *ngFor="let label of labels2">
<label><strong>{{ label }}</strong></label>
</div>
</div>
<div fxLayout="column" fxFlex.xs="50%">
<div fxFlex="25%" class="details">
<label>9178384567</label>
</div>
<div fxFlex="25%" class="details">
<label>Phoenix</label>
</div>
<div fxFlex="25%" class="details">
<label>Male</label>
</div>
<div fxFlex="25%" class="details">
<label>Aug 21, 2019</label>
</div>
</div>
</div>
</mat-card-content>
also i suggest adding following style to properly break text in very small screens
.details > label {
overflow-wrap: break-word;
}
Here is a working demo: https://stackblitz.com/edit/angular-ivy-9vpkl1
UPDATE
In order to have a more compact template create an array that holds labels and data together
datas = [
{label: "ID", text: "1"},
{label: "Mobile", text: "9178384567"},
{label: "Full Name", text: "Robert Williams"},
{label: "City", text: "Phoenix"},
{label: "Email", text: "robert#gmail.com"},
{label: "Gender", text: "Male"},
{label: "Department", text: "Human Resource"},
{label: "Hire Date", text: "Aug 21, 2019"},
]
<mat-card-content fxLayout="row wrap" fxLayoutAlign="start stretch">
<div fxFlex="50%" fxFlex.xs="100%" fxLayout="row" *ngFor="let data of datas">
<div fxFlex="50%" class="details">
<label><strong>{{data.label}}</strong></label>
</div>
<div fxFlex="50%" class="details">
<label>{{data.text}}</label>
</div>
</div>
</mat-card-content>
Demo: https://stackblitz.com/edit/angular-ivy-g9vt6h
I hope it helps.
Related
I got this form:
<div class="container">
<div class="row">
<div class="col-md-5">
<div class="mx-2">
<small class="text-muted">Tablas contenidas en el archivo.</small>
</div>
<textarea rows="10"></textarea>
</div>
<div class="col-md-2">
<div class="col-md-4 my-1 mx-auto">
<button>btn</button>
</div>
<div class="col-md-4 my-1 mx-auto">
<button>btn</button>
</div>
<div class="col-md-4 my-1 mx-auto">
<button>btn</button>
</div>
<div class="col-md-4 my-1 mx-auto">
<button>btn</button>
</div>
</div>
<div class="col-md-5">
<div class="mx-2">
<small class="text-muted">Tablas seleccionadas.</small>
</div>
<textarea rows="10"></textarea>
</div>
</div>
</div>
JSFIDDLE: https://jsfiddle.net/qh8a5Lro/
I want to order Buttons in the middle of the two textarea's but the text on the textarea's is avoiding this. How I can fix it? And I wanna make it responsive.
Any ideas?
https://i.stack.imgur.com/4gBwM.png
https://i.stack.imgur.com/q3amm.png
Thanks for ur help!
I am attempting to make the layout of a container with a row and an accordion beneath it have equal width columns using the bootstrap grid. The problem is with aligning the data within the accordion to the top most row.
My understanding with bootstrap 4 is that the col class should auto-size per column so I would think all 8 columns would be the same width regardless of content.
The top looks okay but the rows below are condensed. Here is an example:
Here is my razor page below:
<body>
<div class="container">
<div class="row">
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].Item)
</div>
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].ItemDescription)
</div>
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].CorpCustomer)
</div>
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].UoM)
</div>
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].SummedOrder)
</div>
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].SummedForecast)
</div>
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].Difference)
</div>
<div class="col">
#Html.DisplayNameFor(model => model.ReportHighLevel[0].Week)
</div>
</div>
</div>
<div class="container">
<div id="accordion">
#{int counter = 0; }
#foreach (var dataVM in Model.CollapseReport)
{
<div class="card">
<div class="card-header" id="heading#(counter)">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse#(counter)" aria-expanded="true" aria-controls="collapse#(counter)">
<div class="row">
<div class="col">
#dataVM.Summary.Item
</div>
<div class="col">
#dataVM.Summary.ItemDescription
</div>
<div class="col">
#dataVM.Summary.CorpCustomer
</div>
<div class="col">
#dataVM.Summary.UoM
</div>
<div class="col">
#dataVM.Summary.SummedOrder
</div>
<div class="col">
#dataVM.Summary.SummedForecast
</div>
<div class="col">
#dataVM.Summary.Difference
</div>
<div class="col">
#dataVM.Summary.Week
</div>
</div>
</button>
</h5>
</div>
<div id="collapse#(counter)" class="collapse" aria-labelledby="heading#(counter)" data-parent="#accordion">
<div class="card-body">
<form method="post">
<input type="hidden" name="var1" value="#dataVM.Summary.CorpCustomer" />
<input type="hidden" name="var2" value="#dataVM.Summary.Item" />
<input type="submit" class="btn btn-default" value="Add to Log" asp-page-handler="AddLog" asp-route-data="#dataVM.Summary.CorpCustomer, #dataVM.Summary.Item)" />
</form>
<div class="container">
#foreach (var item in dataVM.WeeksOfData)
{
<div class="row">
<div class="col">
#item.Item
</div>
<div class="col">
#item.ItemDescription
</div>
<div class="col">
#item.CorpCustomer
</div>
<div class="col">
#item.UoM
</div>
<div class="col">
#item.SummedOrder
</div>
<div class="col">
#item.SummedForecast
</div>
<div class="col">
#item.Difference
</div>
<div class="col">
#item.Week
</div>
</div>
}
</div>
</div>
</div>
</div>
counter++;
}
</div>
</div>
The reason is your btn btn-link button nested in <h5>. .btn class from Bootstrap is with style display: inline-block;, which doesn't take up the 100% width.
Even you set width: 100%; on the button, your columns still won't be aligned because:
.btn has style of white-space: nowrap; hence the texts inside your collapsable heading won't wrap, while the texts inside the collapsable body will.
.btn class has .75rem padding left and right, which will take up the overall row width.
You have a nested container inside your collapsable body. The container has 15px padding left and right, which will take up the overall row width as well.
Hints: you might want to think of a different design / layout.
For example, get rid of the button nested in the heading and use anchor isntead:
<div class="container">
#for (int i = 0; i < 5; i++)
{
<div class="card">
<div class="card-header">
<a href="#" data-toggle="collapse" data-target="#collapse#(i)">
<div class="row">
<div class="col">Item</div>
<div class="col">Item Description</div>
<div class="col">Corp Customer</div>
<div class="col">UoM</div>
<div class="col">Summed Order</div>
<div class="col">Summed Forecase</div>
<div class="col">Difference</div>
<div class="col">Week</div>
</div>
</a>
</div>
<div id="collapse#(i)" class="collapse">
<div class="card-body">
<div class="row">
<div class="col">Item</div>
<div class="col">Item Description</div>
<div class="col">Corp Customer</div>
<div class="col">UoM</div>
<div class="col">Summed Order</div>
<div class="col">Summed Forecase</div>
<div class="col">Difference</div>
<div class="col">Week</div>
</div>
<div class="row">
<div class="col">Item</div>
<div class="col">Item Description</div>
<div class="col">Corp Customer</div>
<div class="col">UoM</div>
<div class="col">Summed Order</div>
<div class="col">Summed Forecase</div>
<div class="col">Difference</div>
<div class="col">Week</div>
</div>
<div class="row">
<div class="col">Item</div>
<div class="col">Item Description</div>
<div class="col">Corp Customer</div>
<div class="col">UoM</div>
<div class="col">Summed Order</div>
<div class="col">Summed Forecase</div>
<div class="col">Difference</div>
<div class="col">Week</div>
</div>
</div>
</div>
</div>
}
</div>
Screenshot:
I have to display a series of cards using ng-repeat. Something like.
What I am currently doing is
<ion-view view-title="Active">
<div class ='child_div_1'>
<div class="card cardS" collection-item-width="'20%'" collection-item-height="40%">
<div class="item item-text-wrap">
<p>dljfweiuf</p>
</div>
</div>
</div>
<div class ='child_div_2'>
<div class="card" collection-repeat="item in items" collection-item-width="'25%'" collection-item-height="60%">
<div class="item item-text-wrap " id="cards">
{{item}}
</div>
</div>
</div>
</div>
What I am getting in my view is
Can anyone help me with how to create gap between the cards the gap between two cards.
add padding css property to the ng repeating div
<div class ='child_div_2'>
<div class="card" collection-repeat="item in items" collection-item-width="'25%'" collection-item-height="60%" style="padding: 15px;">
<div class="item item-text-wrap " id="cards">
{{item}}
</div>
</div>
</div>
I have this free Philippines texting site and as you can see I can't align the captcha image with the textbox. It is below the captcha image. How can I align the textbox? Here is my code. I am using foundation css framework.
<body>
<div class="row">
<div class="large-12 columns">
<div class="nav-bar right">
<ul class="button-group">
<li>Free SMS</li>
<li>Contact Me</li>
</ul>
</div>
<img src="img/smsbanner.png">
<hr/>
</div>
</div>
<div class="row">
<div class="large-4 large-centered columns">
<div class="large-12 columns">
<form action="sendsms.php" method="POST" name="txtform" data-abide>
<div class="row">
<div class="large-12 columns">
<div class="row">
<div class="small-3 columns">
<label for="right-label" class="right">+63</label>
</div>
<div class="small-9 columns">
<input type="text" name="txt_number" placeholder="10 digit number" required pattern="number" maxlength="10"/>
<small class="error">Phone number is required.</small>
</div>
</div>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<textarea rows="10" cols="50" placeholder="Message" required maxlength="200" name="txt_body" style="resize:none;"
onKeyDown="limitText(this.form.txt_body,this.form.countdown,200);"
onKeyUp="limitText(this.form.txt_body,this.form.countdown,200);"></textarea>
<small class="error">Your message is required.</small>
<div class="row">
<div class="small-5 columns">
<img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" />
</div>
<div class="small=7 columns">
<input type="text" name="captcha_code" size="10" maxlength="6" style="width:100px;"/>
[ Different Image ]
</div>
</div>
<div class="row">
<div class="small-4 columns">
<input readonly type="text" name="countdown" size="3" value="200">
</div>
<div class="small-8 columns">
characters left.
</div>
</div>
</div>
</div>
<div class="row">
<div class="large-12 large-centered columns">
<input type="submit" class="button expand" value="Send" name="send_btn"/>
</div>
</div>
</form>
</div>
</div>
</div>
<footer class="row">
<?php include 'footer.php'; ?>
</footer>
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
Looks like a pretty minor problem.
<div class="small=7 columns">
should be
<div class="small-7 columns">
1) I am trying to stretch the children divs to 60% and align it in the center but it is not working. I am using flex to stretch the size of the div to 60%. See example http://plnkr.co/edit/eaLjJDbjL1KnOI4jLYyO?p=preview
<div layout="column" layout-align="center">
<div style="background-color:#00A000;height: 40px;" flex="60">
</div>
<div style="background-color:#004444;height: 40px;" flex="60">
</div>
<div style="background-color:#0077b3;height: 40px;" flex="60">
</div>
2) In Angularjs Material document it is mentioned that "to customize the size and position of elements in a layout, use flex, offset, and flex-order attributes", I don't see an example of offset.
This is what you need to do..
<div layout="column" layout-align="center">
<div layout="row" layout-align="center center">
<div style="background-color:#00A000;height: 40px;" flex="60">
</div>
</div>
<div layout="row" layout-align="center center">
<div style="background-color:#004444;height: 40px;" flex="60">
</div>
</div>
<div layout="row" layout-align="center center">
<div style="background-color:#0077b3;height: 40px;" flex="60">
</div>
</div>
</div>
Read more about layout here
+1 for nitins answer. It really helped me with my issue. Here is the plunker showing his answer in a different way using angular material cards.
The html:
<section class="content-section gridListdemoBasicUsage">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<h1 class="text-center">The Different Ways SharePoint can help define your business</h1>
<!-- Separator -->
<md-divider ng-style="{'background': 'rgba(255, 102, 51, 0.7)'}"></md-divider>
</div>
</div>
<div layout="row" layout-align="center" data-ng-style="{'width': '100%'}">
<div class='md-padding' layout="row" layout-align="center" layout-wrap>
<md-card class="md-whiteframe-9dp" data-ng-style="{'width': '350px', 'border-radius': '6px'}" data-ng-repeat="card in spcVM.serviceCards" layout-padding>
<a data-ng-if="card.imagePath" ui-sref="{{card.link}}"><img layout-fill src="{{card.imagePath}}" class="img-rounded" alt="{{card.imageAlt}}" /></a>
<md-card-content>
<div>
<h4>{{card.title}}</h4>
<md-divider ng-style="{'background': 'rgba(255, 102, 51, 0.7)'}"></md-divider>
<br />
<p>{{card.mainContent}}</p>
</div>
</md-card-content>
<md-card-footer>
<div class="md-actions" layout="row" layout-align="center end">
<md-button ng-click="card.action($event)">View</md-button>
</div>
</md-card-footer>
</md-card>
</div>
</div>
</section>
The above is in a container-fluid div.