I am working on the Ionic 5 application for iPad/Tablet. I want to increase the font size of ion-input for full app.
I have tried various options
ion-input {
font-size: 20px !important;
}
input {
font-size: 20px !important;
}
But none of it is increasing the font size. I have even tried to increase the browser inspect element there also it has increased the space but font size is same.
My code structure is
<ion-item class="ion-padding-horizontal">
<ion-label class="input-label" position="stacked">Email</ion-label>
<ion-input class="input-text" type="email"></ion-input>
</ion-item>
When I give font size in the input-text class it is just increasing the size of the input, not the font size
make sure you input is in an ion-item element and then give it your class like this:
CSS:
.size {
font-size: 30px;
}
HTML:
<ion-item>
<ion-input class="size"></ion-input>
</ion-item>
I tested it just now. it works.
Related
I have an ion-item with ion-avatar and ion-label with large text.
For showing full text in ion-label i added a class 'ion-text-nowrap' to ion-label.
It works fine.
But the problem is ion-avatar automatically placed to vertical center of ion-item.
I don't need to align avatar vertical align middle. I want that align left-top of ion-item. How can i do that?
This is my code:
<ion-item>
<ion-avatar slot="start">
<img [src]="img">
</ion-avatar>
<ion-label class="ion-text-nowrap">
<p>{{text}}</p>
</ion-label>
</ion-item>
There are no css properties to achieve this in Ionic.
But it is possible by overwriting the css of the ion-avatar and ion-label.
Change the position of the avatar to absolute and place it in the top corner of the item. Then adjust the label margin to place the text back where you want it.
ion-avatar{
position: absolute;
top: 0px;
left: 0px;
}
ion-label{
margin-left: // size needed
}
Example output:
Ionic 4 - angular 7
ion-item-bg - CSS
.ion-item-bg{
--background: transparent;
--color:#fff;
border-bottom: 1px solid #fff
}
<ion-item class="ion-item-bg" lines='none'>
<ion-label class="open-sans-light" position="floating" style="--color:#fff;">
email
</ion-label>
<ion-input formControlName='email' autocomplete='off'></ion-input>
</ion-item>
If we save the credentials, then on reloading the UI looks like the image
Tried autocomplete off and all , but still facing the issue.
You have only said what is wrong, not what you actually want.
I'm assuming you want the textbox to be transparent as well?
Looks like you need to style the ion-input.
ion-input {
--background: transparent;
}
If that doesn't work sometimes I've had to use:
ion-input {
--background: transparent;
background: transparent;
}
Or even put !important;'s on them.
I'm using Ionic 4 and using Tabs layout.
I have to design the tabs items like
For this, the tabs.page.html is like
<ion-tabs>
<ion-tab-bar slot="bottom" color="primary">
...
<!-- center button with round border -->
<ion-tab-button tab="ride" class="tab-btn-ride">
<ion-icon name="bicycle"></ion-icon>
<ion-label>Ride</ion-label>
</ion-tab-button>
...
</ion-tabs>
To make the button round, here is the css
.tab-btn-ride {
width: 4rem !important;
height: 5rem;
border-radius: 50% 50%;
box-shadow: 0 0 0 1.5pt #ff9823;
margin-bottom: 2rem;
max-width: 5rem;
z-index: 10;
border: 3px solid white;
}
This looks fine in the browser (above image) while development. But after generating apk, it looks like the below image in Android device. The upper part is clipped or hidden below the page view.
I tried increasing the z-index value but no luck.
The round image cut because of footer height. So resolved this issues as below
Increase footer height
Reduced round image size.
I have a button with shape round as follows:
<ion-button expand="full" class="shadow-red" shape="round">Signup with</ion-button>
The class shadow-red is:
.shadow-red{
box-shadow: 0px 14px 25px rgba(182, 30, 30, 0.59);
border-radius: 5px;
}
And the result is:
So I tried many different ways to change the round shape but since it isn't a css class doing the following didn't work.
.round{
border-radius:5px!important;
}
I tried adding border-radius:5px!important; to ion-button class, button, .btn, and many other combinations but none of them worked.
I have also tried to add to variables.css the following lines and none of them worked:
--ion-button-round-border-radius: 5px;
--ion-button-border-radius: 5px;
--ion-border-radius: 5px;
--border-radius: 5px;
....
Don't use the shape attribute, now you can change the look of the button to your wishes. One thing to change is the expand attribute. If you set it to full, you remove the left and right borders (see in docs). And so you can't set or change the border-radius. Set it to block and you will still have a full-width button.
<ion-button expand="block" class="shadow-red">Signup with</ion-button>
Use the following CSS custom properties as described in the Ionic 4 docs.
.shadow-red{
--border-radius: 5px;
--box-shadow: 0px 14px 25px rgba(182, 30, 30, 0.59);
}
Result:
Following code worked for me. As per your need change the height and width value to meet your requirement.
<ion-button slot="end" shape = "round" style="height: 3rem; width : 3rem">
<ion-icon name="create-outline" slot="icon-only"></ion-icon>
</ion-button>
Posting here for future references.
If you want to change the ionic button radius we can use following css. it is working on expand="block" attribute
ion-button {
--border-radius: 20px;
border-radius: 20px;
}
But in ionic button, when we use expand="full" attribute it does not work. so to overcome this limitation we can use CSS Pseudo-elements.
to add a border radius to the bellow button
<ion-button fill="solid" type="submit" color="primary" expand="full" >Login</ion-button>
as bellow image we need to select the native element within the shadow DOM
we can use below Pseudo-elements selector
ion-button::part(native) {
--border-radius: 20px;
border-radius: 20px;
}
above will add the radius on the ionic button with expand="full" attribute
Is there a way to achieve multiline ellipsis text in ionic 2. I have a card view and need to restrict maximum 2 lines to be showed inside it with vertical center alignment. I tried webkit css option but it is not working. I saw similar questions asked by others but couldn't figure out an answer for it.
Below is my html code
<ion-content class="cards-bg light-gray">
<ion-list>
<ion-card *ngFor="let od of orderDetails” class="fade_logo">
<ion-card-content> {{od.description}} </ion-card-content>
</ion-card>
</ion-list>
</ion-content>
Here the order description is long text, I just need to show only 2 lines.
It depends on font size and line height but put this in your .scss file and also change the height: to get the best result.
ion-card-content {
display: block;
display: -webkit-box;
height: 60px;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}