Showing posts with label css. Show all posts
Showing posts with label css. Show all posts

Wednesday, January 23, 2019

Show image loader in ionic | html



In above image please check 1,2,3 cases.
Case 1 - Image is not loaded so here loader is showing.
Case 2 - Image is half loaded so still image loader is showing.
Case 3 - Image is fully loaded so loader is not showing.


Solution -

Hey guys, There are many third-party libraries available for this but when I try those libraries nothing working properly. So I found a solution with the help of CSS. This is very simple and easy to use. In this solution, we will show loader git until the image load in img tag. So now check below details for solution -


First, in your CSS file add below class -

.default-img-loader{
  background: url('../assets/img/loader.gif') no-repeat center;
}

This class will add a background image to the image tag. Here we used below property -
url('../assets/img/loader.gif')  - Make sure to update path according to your project.
no-repeat  - This will not repeat image in background.
center - This will place the image in center.


Now, In your HTML (template) file add “default-img-loader” class in image tag.
Eg- 

<img class=“default-img-loader” src=“your image url path of server”>


Note - Gif image size should be 16 × 16 OR 18 × 18 for batter experience. You can download loader from below URL -


Feel free to post a comment if you face any issue during the implementation of this. 



This will help in this case when you are fetching images from server and image size is very long. With the help of this solution, you can show loader until the image fully load. This will work for ionic, HTML, angular, PhoneGap etc. This works for me. I develope ionic app and its working perfect in this.


  

Monday, October 15, 2018

iPhone XR / XS / XS Max CSS media queries



Handling the Notch on iPhone X / XR / XS / XS Max OR iPhone media queries for responsive design  -

Media queries are very useful to modify your website or hybrid apps depending on a device resolution/type. This is very important to manage resolution in different devices. It help us to present batter view of app/website to users. Below are the examples for iPhone XR / XS / XS Max CSS media queries -


/* Apple iPhone XR 1792x828px at 326ppi Media Queries */
@media only screen 
    and (device-width : 414px) 
    and (device-height : 896px) 
    and (-webkit-device-pixel-ratio : 2) { }

/* Apple iPhone XS 2436x1125px at 458ppi Media Queries */
@media only screen 
    and (device-width : 375px) 
    and (device-height : 812px) 
    and (-webkit-device-pixel-ratio : 3) { }

/* Apple iPhone XS Max 2688x1242px at 458ppi Media Queries */
@media only screen 
    and (device-width : 414px) 
    and (device-height : 896px) 
    and (-webkit-device-pixel-ratio : 3) { }


Below are the examples for iPhone X / 8 / 8 Plus CSS media queries -

/* Apple iPhone X Media Queries */
@media only screen 
    and (device-width : 375px) 
    and (device-height : 812px) 
    and (-webkit-device-pixel-ratio : 3) { }

/* Apple iPhone 8 Media Queries */
@media only screen 
    and (device-width : 375px) 
    and (device-height : 667px) 
    and (-webkit-device-pixel-ratio : 2) { }

/* Apple iPhone 8 Plus Media Queries */
@media only screen 
    and (device-width : 414px) 
    and (device-height : 736px) 
    and (-webkit-device-pixel-ratio : 3) { }



Note : If you are looking for a specific orientation. Follow below rules -

For portrait orientation add below rule :

    and (orientation : portrait) 


For landscape orientation add below rule :

    and (orientation : landscape) 



Now use above media query in your project. It helps me a lot. If you have any query please post in a comment. 

For other all Media Queries please check this link - https://allexperts16.blogspot.com/2018/06/media-queries-for-standard-devices.html

It has Media Queries for - iPads, iPad 3, iPhone 4, iPhone 5, iPhone 6, iPhone 6+, Samsung Galaxy S3, Samsung Galaxy S4, Samsung Galaxy S5, and many more. 


Saturday, June 9, 2018

Fade in fade out animation by css in ionic 2 | ionic 3 | ionic 4 | angular2 | angular4

Use below code in your SCSS file :


.fadein-out-border{ transition: 1s ease-in-out all;}


Code for your HTML Template File :


 <p [ngClass]=“showData?’fadein-out-border’:””> Data will hide by fade in / fade out</p>

Here you need to manage "showData" as a dynamic variable in TS file, Which will we true and false based on your condition. So when it goes true or false you can see CSS effect.

Media queries for standard devices

This is css-tricks which i found :-

/* Smartphones (portrait and landscape) ———– */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ———– */
@media only screen and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ———– */
@media only screen and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ———– */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ———– */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ———– */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
/* Styles */
}
/**********
iPad 3
**********/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* Desktops and laptops ———– */
@media only screen and (min-width : 1224px) {
/* Styles */
}
/* Large screens ———– */
@media only screen and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ———– */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* iPhone 5 ———– */
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6 ———– */
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6+ ———– */
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S3 ———– */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S4 ———– */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
/* Samsung Galaxy S5 ———– */
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}

OR

@media (min-width:320px) { /* smartphones, iPhone, portrait 480×320 phones */ }

@media (min-width:481px) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ }

@media (min-width:641px) { /* portrait tablets, portrait iPad, landscape e-readers, landscape 800×480 or 854×480 phones */ }

@media (min-width:961px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ }

@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }

@media (min-width:1281px) { /* hi-res laptops and desktops */ }

OR


/* Smartphones (portrait and landscape) ———– */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {/* Styles */}

/* Smartphones (landscape) ———– */
@media only screen and (min-width : 321px) {/* Styles */}

/* Smartphones (portrait) ———– */
@media only screen and (max-width : 320px) {/* Styles */}

/* iPads (portrait and landscape) ———– */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {/* Styles */}

/* iPads (landscape) ———– */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {/* Styles */}

/* iPads (portrait) ———– */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {/* Styles */}

/* Desktops and laptops ———– */
@media only screen and (min-width : 1224px) {/* Styles */}

/* Large screens ———– */
@media only screen and (min-width : 1824px) {/* Styles */}

/* iPhone 4 ———– */
@media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) {/* Styles */}



For iPhone X / 8 / 8 Plus / XR / XS / XS Max check below link -
https://allexperts16.blogspot.com/2018/10/iphone-xr-xs-xs-max-css-media-queries.html  

Mobile screen size resolution android | ios

This is  resolutions which i found :-



iPhone

ModelDPPPIRatioViewport
iPhone 2g, 3g320 x 480163 PPI (@1x)3:2320 x 480
iPhone 4320 x 480326 PPI (@2x)3:2640 x 960
iPhone 5320 x 568326 PPI (@2x)16:9640 x 1136
iPhone 6375 x 667326 PPI (@2x)16:9750 x 1334
iPhone 6+414 x 736401 PPI (@3x)16:91080 x 1920


iPad

ModelDPPPIRatioViewport
iPad + Mini768 x 1024132 PPI (@1x)4:3768 x 1024
iPad (Retina)768 x 1024264 PPI (@2x)4:31536 x 2048


Wearables

ModelViewportPPI
Apple Watch 38mm272 x 340326 PPI @2x
Apple Watch 42mm312 x 390326 PPI @2x
Pebble Original and steel Monochrome144 x 168176 PPI
Pebble Time Color display144 × 168182 PPI
Galaxy Gear320 x 320275 PPI
Android Wear320 x 320348 PPI

Common Smartphones values :-

namephys.
width
phys.
height
CSS
width
CSS
height
pixel
ratio
phys. ppiCSS ppi
Xiaomi Mi 4108019203606403441288
Xiaomi Mi 3108019203606403441288
Sony Xperia Z3108019203605983424288
Sony Xperia Z108019203606403443288
Sony Xperia S72012803606402342192
Sony Xperia P5409603606401.5275144
Samsung Galaxy S7, S7 edge144025603606404534384
Samsung Galaxy S6144025603606404577384
Samsung Galaxy S5108019203606403441288
Samsung Galaxy S4 mini5409603606401.5256144
Samsung Galaxy S4108019203606403441288
Samsung Galaxy S3 mini4808003205331.5233144
Samsung Galaxy S372012803606402306192
Samsung Galaxy S24808003205331.5217144
Samsung Galaxy S4808003205331.5233144
Samsung Galaxy Note 4144025603606404515384
Samsung Galaxy Note 3108019203606403386288
Samsung Galaxy Note 272012803606402267192
Samsung Galaxy Note80012804006402285192
Samsung Galaxy Nexus72012003606002316192
Pantech Vega n°6108019203606403373288
Motorola Nexus 6144025604126903.5493336
Microsoft Lumia 92576812803204802.4332220
Microsoft Lumia 92076812803204802.4332220
Microsoft Lumia 9004808003204801.5217144
Microsoft Lumia 83072012803204802294192
Microsoft Lumia 6204808003204801.5252144
Microsoft Lumia 1520108019204327682.5367240
Microsoft Lumia 102076812803204802.4332220
LG Optimus G76812803846402318192
LG Nexus 5108019203606403445288
LG Nexus 476812803846402320192
LG G5144025603606404538384
LG G4144025603606404538384
LG G3144025603606404538384
Lenovo K900108019203606403401288
HTC One108019203606403468288
HTC Evo 3D5409603606401.5256144
HTC 8X72012803204803341288
Blackberry Z3072012803606402295192
Blackberry Z1076812803846402355192
Blackberry Torch 9800360480360480118796
Blackberry Q107207203463462328192
Blackberry Passport144014405045043453274
Blackberry Leap72012803906952294177
Blackberry Classic7207203903901.8294177
Apple iPod Touch64011363205682326192
Apple iPhone 775013343756672326192
Apple iPhone 6, 6s75013343756672326192
Apple iPhone 6 Plus, 6s Plus108019204147363401249
Apple iPhone 564011363205682326192
Apple iPhone 46409603204802326192
Apple iPhone 3320480320480116396


Top selling Android phones
ModelDPDensityPPIRatioViewport
Galaxy SIII360 x 640200% (XHDPI)306 PPI16:9720 x 1280
Galaxy SII320 x 533150% (HDPI)217 PPI5:3480 x 800
Google Nexus 4384 x 640200% (XHDPI)318 PPI5:3768 x 1280
Galaxy Nexus360 x 640200% (XHDPI)316 PPI16:9720 x 1280
Galaxy SIV360 x 640300% (XXHDPI)441 PPI16:91080 x 1920
Galaxy Note II360 x 640200% (XHDPI)267 PPI16:9720 x 1280
Galaxy S Plus320 x 533150% (HDPI)233 PPI5:3480 x 800
Galaxy S320 x 533150% (HDPI)233 PPI5:3480 x 800
Galaxy Note400 x 640200% (XHDPI)285 PPI8:5800 x 1280
HTC One360 x 640300% (XXHDPI)469 PPI16:91080 x 1920
HTC Desire240 x 400200% (HDPI)252 ppi5:3480 x 800

Common Tablets values

 
name
phys.
width
phys.
height
CSS
width
CSS
height
pixel
ratio
phys. ppi
CSS ppi
Apple iPad Pro20482732102413662265192
Apple iPad 3, 4, Air, Air21536204876810242264192
Apple iPad 1, 276810247681024113296
Apple iPad mini 2, 31536204876810242326192
Apple iPad mini76810247681024116396
Samsung Galaxy Tab 3 10″80012808001280114996
Samsung Galaxy Tab 2 10″80012808001280114996
Samsung Galaxy Tab (8.9″)80012808001280117096
Samsung Galaxy Tab 2 (7″)60010246001024117096
Samsung Nexus 101600256080012802300192
HTC Nexus 91538204876810242281192
Asus Nexus 7 (v2)108019206009602323192
Asus Nexus 7 (v1)80012806049661.325216127
LG G Pad 8.3120019206009602273192
Amazon Kindle Fire HD 8.91200192080012801.5254144
Amazon Kindle Fire HD 780012804808001.5216144
Amazon Kindle Fire60010246001024116796
Microsoft Surface Pro 314402160102414401.5 / 1.4216144
Microsoft Surface Pro 21080192072012801.5207144
Microsoft Surface Pro1080192072012801.5207144
Microsoft Surface76813667681366114896
Blackberry Playbook60010246001024116996




Windows Phones

ModelPPIRatioViewportMarket Share
Nokia Lumia 520233 PPI5:3480 x 80023.2%
Nokia Lumia 630221 PPI16:9480 x 8549.7%
Nokia Lumia 625199 PPI5:3480 x 8007.1%
Nokia Lumia 530245 PPI16:9480 x 8545.1%

Windows tablets

1024 x 7681280 x 8001280 x 10241366 x 7681920 x 10802560 x 1440