ionic4 making segment on ios to look like they look on android with css - ionic-framework

i am trying to make the segments on ios look the same way as they look on android. refer https://beta.ionicframework.com/docs/api/segment
i tried to play with the css properties like
segment-button-checked {
--background-checked: transparent !important;
--color-checked: white !important;
border-bottom: 1 px solid white
}
ion-segment-button {
--color: #8CA2A5;
--border-color: transparent !important
}
selected button properties does not work this way. and overall visually does not look very nice as it looks on adroid

EDIT: Ionic 4 solution
Set the segment height to match header height
ion-segment{
height: 44px;
}
Style segment button with color for the un-active segment.
Remove border and border-radius.
ion-segment-button{
font-size: 16px;
color: var(--ion-color-medium);
border: 0px;
border-radius: 0px;
}
.segment-button-checked class is used to style active state of segment.
.segment-button-checked{
background: #FFF;
color: var(--ion-color-primary);
border-bottom: 3px solid var(--ion-color-primary);
}
Original segment button:
After styling:

This can easily done by setting mode as md
<ion-segment mode="md">
<ion-segment-button value="friends">
<ion-label>Friends</ion-label>
</ion-segment-button>
<ion-segment-button value="enemies">
<ion-label>Enemies</ion-label>
</ion-segment-button>
</ion-segment>

With ionic 4 an ion-label was added and so the best approach is to customize it like this
.segment-button {
ion-label {
color: var(--ion-color-medium);
}
}
.segment-button-checked {
ion-label {
color: var(--ion-color-light) !important;
}
}
this will work well!

Related

How to make ion-select select-icon position right but just icon, select-text position left

I want it to have a standart design on ionic input elements. I have an ion-select element and this element inside select box text align-left but I want select-icon align right. I do on HTML element like that: https://ibb.co/99YXc8B. But I am not doing in the sccs style. I try a lot. Stackblitz link: https://stackblitz.com/edit/ionic-fdqf4z?file=pages%2Fhome%2Fhome.scss
Replace your CSS with this CSS code.it will works.
[inline-icon] {
font-size: 2em !important;
padding-right: 3px !important;
color: #808080ba !important;
}
.try{
color: red;
width:100%;
}
ion-select
{
max-width: 100%;
}

Change color and Font Size icons Ion-toolbar

I'm trying to change the color and the size of the letter inside the ion-toolbar but without success, what I've tried so far:
ion-toolbar {
--background: var(--custom-primary); //works
--color: #FFFFFF; //works letters, not icon
ion-buttons {
font-weight: bold; //works
--icon-font-size: 10px !important;
}
ion-back-button {
--icon-font-size: 30px !important;
}
}
You can directly style your toolbar in the template. E.g.:
<ion-toolbar color="green">
...
</ion-toolbar>
Check out these docs https://ionicframework.com/docs/theming/advanced#themes. Theming ionic core components like the ion-toolbar is a little different.

Ion Refresher Background color wont change ionic

I'm using an ionic refresher to refresh content on a page in my application. However, when I pull up the ion-refresher, background does not get fully set to the color I want.
This is a CSS class I'm applying to the ion-refresher:
ion-refresher {
background-color: #dedede;
}
ion-refresher-content {
background-color: #dedede;
}
And this it what the result looks like:
How do I remove the white gap between the ion refresher and the main content?
On Ionic 4, this CSS worked for me:
ion-refresher-content {
padding-bottom: 200px;
background-color: yellow;
.refresher-pulling {
position: fixed;
top: 50px;
}
}
The padding-bottom: 200px; fills up the space to show the yellow color, but it also introduces a new issue. The refresher arrow disappears! In order to keep the arrow in place and make it function normally, the .refresher-pulling and its corresponding styles are added. This way, now the app background color shows without any white gaps and also the spinner stays in place.
Hope this helps someone.
When you pull up, one div was been created called fixed-content
For remove the gap just add .fixed-content in your .scss
Example:
.fixed-content{
background:#dedede;
}
This is what got it working for me.
ion-refresher-content {
padding-bottom: 100px;
background-color: #dedede;
}
#devner's solution is not working correctly with iPhone X and kind (i.e. devices with safe-area-inset).
Proper solution (Ionic 4):
ion-refresher-content {
position: relative;
padding-bottom: 200px;
background-color: var(--base-background-color-body);
.refresher-pulling, .refresher-refreshing {
position: relative;
top: 30px;
}
}
Appendix: best UX on my opinion can be achieved with next HTML:
<ion-refresher slot="fixed" pullFactor="0.5" (ionRefresh)="onPullToRefresh($event)">
<ion-refresher-content
pullingIcon="refresh"
refreshingSpinner="crescent"
></ion-refresher-content>
</ion-refresher>

CSS div buttons not working on Iphone or Ipad

I am working on a web base app for my school with different versions of CSS for handheld, tablet and desktop. I am using media queries for this. The app is almost done and it works correctly on almost all browsers and android. The app looks awesome on Iphone/Ipad however buttons do not work making the app useless in these devices.
This is what I have:
//Source code
<div id="signinbutton" class="blue_button">Sign In</div>
//desktop.CSS
.blue_button {
width: 130px;
height: auto;
padding: 8px;
margin: 0% auto 20% auto;
background-image:url(../../images/bluebar5.png);
color: #FFF;
text-align: center;
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 14pt;
font-weight: bolder;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
cursor: default;
}
.blue_button:hover {
opacity: 0.7;
}
//Handheld.css (this overwrites css on desktop)
.blue_button {
width: 260px;
font-size: 18pt;
background-image:url(../../images/bluebar6.png);
}
I tried applying the style to #signinbutton without success.
You should use a <button> or <input type="button"> tag instead of a div. While the <div> button functionality may work in some browsers, it can be a bit of a hack compared to the traditional button tags
You can wrap your div around <a> like this. It's perfectly valid with html5 now.
<div id="signinbutton" class="blue_button">Sign In</div>
You just need to adjust
Reference:
https://css-tricks.com/snippets/jquery/make-entire-div-clickable/
Try adding to the style of the div {cursor:pointer}.

adding a border-radius without padding to fancybox2

I'm using fancybox 2 and I can get rid of the padding around the outside of the frame, but then I lose the border-radius that it comes with.
What I want is a border-radius around the main content inside the frame. So I tried going into the css and adding a border-radius to the fancy-box inner selector and it won't work. How can I give the frame a rounded corner without a border?
If anyone can help me with this that would be great!
Try this code it worked for me
Add custom classes after fancy box on complete method.
Ex.
HTML
Login
JS
$(document).ready(function(e) {
$(".signin-ovr").fancybox({
afterLoad : function(){
$("#fancybox-content").addClass('fancybox-content-cust');
$(".fancybox-bg").addClass('fancybox-bg-cust');
$("#fancybox-outer").addClass('fancybox-outer-cust');
}
});
});
CSS
.fancybox-content-cust {
overflow: visible !important;
border: 10px solid #FFFFFF;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
}
.fancybox-bg-cust{
display: none;
}
.fancybox-outer-cust {
background: transparent !important;
}
Then you will get border radius to the overlay box.
for fancybox v2 round borders
.fancybox-outer, .fancybox-inner, .fancybox-skin {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border-radius: 10px!important;
}
CSS3 has a border radius property ironically enough entitled border-radius there are a few specific variations ie, Firefoxes moz-border-radius.
It is used like so:
#div-id .specific-class {
border-radius: 10px;
}
If you only want one rounded it has the ability to be modified like so
border-top-left-radius:2em;
border-top-right-radius:2em;
border-bottom-right-radius:2em;
border-bottom-left-radius:2em;
I hope this answers your question.