<Label paddingTop="10" textWrap="true" text="Maxim Savelov"
horizontalAlignment="center"></Label>
It gives me the following result:
Maxim
Savelov
But I need this:
Maxim
Savelov
The CSS property for text alignment works here.
<Label style="text-align: center; padding-top: 10" textWrap="true" text="Maxim Savelov"></Label>
Related
I've got a nativescript app. I have a situation were I need to display text dynamically, so I don't know how much text and how much lines it will be.
The text need to wrap over multi lines and has to be aligned in center horizontally (not vertically, simply same distance to left and right) always.
Therefore I guess <Label> isn't the right element, because it is not for multiline (if I got this right?!).
So I choose <TextView>, but here the styles text-align: center got ignored.
So in documentation I found constructor textAlignment https://docs.nativescript.org/api-reference/modules/_ui_text_base_#textalignment, but I don't get it to work.
Doesn't work:
<TextView text="{{ taskString }}"
horizontalAlignment="center"
editable="false"
></TextView>
Doesn't work:
<TextView text="{{ taskString }}"
textAlignment="center"
editable="false"
></TextView>
Please let me know, what obvious I didn't get here. Thx.
Upate:
Label with textWrap="true" normally works just fine. But I have a "complex" <ContentView> <FlexboxLayout> combination, that seems to cause the problem with the height of Label that doesn't get updated.
Solution in my case:
Just don't use a <FlexboxLayout> <FlexboxLayout> ... </FlexboxLayout> </FlexboxLayout>solution. That won't calculate the height of Label dynamically.
Nativescript Playground:
https://play.nativescript.org/?template=play-ng&id=SnNmkQ
Label can be multiline if you enable textWrap
XML
<Label text="{{ taskString }}" textWrap="true" ...
Or
CSS
Label {
white-space: normal;
}
I'm working on a big datatable from PrimeNG and I have one column that I want to be frozen and not allowing the user to move it from its place, it must always be the second column of the table, unlike the other columns.
<p-column field="new" sortable="custom" styleClass="text-center">
<ng-template pTemplate="header" let-col>
<nd-table-title [field]="col.field"></nd-table-title>
</ng-template>
<ng-template let-col let-order="rowData" pTemplate="body">
<div #newAffDiv style="display:inline-block;position:relative">
<span class="badge" style="margin-right: -10px;border-radius: 18px; border: none; height: 25px;color: white; background-color: #527edb;">New</span>
</div>
</ng-template>
<ng-template pTemplate="footer" let-col>
<nd-table-title [field]="col.field"></nd-table-title>
</ng-template>
</p-column>
To disable the column ordering for particular columns use [pReorderableColumnDisabled]="true/false" if the value is true, column gets freeze, if false it can be reordered.
How can I add md-icon elements next to inputs like in angular material 1 and this screenshot from google contacts:
Google contacts edit form
I know I can use mdPrefix but I like this style better.
Code example:
<md-input-container>
<md-icon mdPrefix>star</md-icon>
<input placeholder="Test" mdInput />
</md-input-container>
The icon inside the input field and I'd like it to be next to it:
Using some css tricks, I was able make something close to the the provided screenshot.
css to position icons:
/deep/ .mat-icon {
color: grey;
width: 24px;
margin: 20px 40px 0 0;
}
html:
<div style="display: flex">
<md-icon >email</md-icon>
<md-input-container >
<input mdInput placeholder="Email">
</md-input-container>
</div>
Code example
I am trying to create a border-radius and border-color around a StackLayout but for some reason the styles doesn't get applied... I am using the Nativescript core-light theme, not sure if that can override my inline styles? Any idea what i'm doing wrong?
my code:
<StackLayout borderRadius="5px" borderColor="blue">
<Label class="body" [text]="'Description: ' + product.Description"></Label>
<Label class="body" [text]="'POS Description: ' + product.POSDescription"></Label>
<Label class="body" [text]="'POS price: R' + product.POSPrice"></Label>
<Label class="body" [text]="'Stock On Hand: ' + product.StockOnHand"></Label>
</StackLayout>
You need to set explicitly borderWidth and your code will work.
e.g.
<StackLayout borderRadius borderWidth="2" borderRadius="15" borderColor="blue">
Notice that I am using DPs (device independent pixels) instead of px which in the mobile world with different screen densities and resolutions should be the better approach.
You can also use CSS for your borders
e.g.
.borders {
border-width: 2;
border-color: red;
border-radius: 20;
}
It's possible change text of label with image? For example, #unaestrella have text "UnaEstrella" and i want clear text (or simply add image with padding or similar) and show an image from http://www.domain.com/images/unaestrella.png. It's this possible?
<ul class="radio_list">
<li>
<label for="unaestrella">
<input id="unaestrella" type="radio" value="unaestrella" name="topics"/>
UnaEstrella
</label>
</li>
<li>
<label for="dosestrellas">
<input id="dosestrellas" type="radio" value="dosestrellas" name="topics"/>
DosEstrellas
</label>
</li>
</ul>
Yes, it's possible but use a class for the label, because #unaestrella is the id that you have already used for the input and an ID must be unique, one ID must be assigned to only one element.
CSS:
.unaestrella{
background : url('https://m.dominos.co.uk/m/iphone/assets/img/common/icon-single-small.png') no-repeat right;
padding: 0 25px 0 0;
cursor:pointer;
}
HTML;
<label class="unaestrella" for="unaestrella">
<input id="unaestrella" type="radio" value="unaestrella" name="topics" />
</label>
EXAMPLE.
Add an <img/> element into your <label/> like this :
In html (http://jsfiddle.net/kyjey/)
<ul class="radio_list">
<li>
<input id="unaestrella" type="radio" value="unaestrella" name="topics"/>
<label for="unaestrella">
<img src="http://www.buscatuspa.com/wp-content/themes/Avada/images/unaestrella.png"/>
</label>
</li>
</ul>
Edit to fit author requirement using jQuery (http://jsfiddle.net/kyjey/2/)
$(function() {
$('#unaestrella').next('label').empty().append('<img src="http://www.buscatuspa.com/wp-content/themes/Avada/images/unaestrella.png"/>');
})
I can solve this with css:
ul.radio_list li label[for=unaestrella] {position:relative !important;float:left !important;line-height:25px !important;background-image:url(images/unaestrella.png);background-position:top left;background-repeat:no-repeat !important; width:100% !important;color:transparent !important;}
But it's possible with jQuery for delete text?