Jump to content

Custom css for iPhone/mobile only

Recommended Posts

Site URL: https://www.dfwmicropigmentation.com

Hi ya'll,

Is it possible to style only for mobile/iPhone?

For example, I hav the following css for controlling padding on my home page, but I want to decrease the padding-top a little more for iPhone:

div#home-page {
  padding-top:10px;
  padding-left:0px;
  padding-right:0px;
}

Do you use the same code again, but wrapped in a css for mobile? How is that done correctly?

Thanks so much!

 

Link to comment
  • Replies 3
  • Views 1.5k
  • Created
  • Last Reply

Wrap your CSS in @media query for iPhone. https://css-tricks.com/snippets/css/media-queries-for-standard-devices/

If you want to apply on Mobile, wrap in this query

@media screen and (max-width:640px) {
your CSS here
}

 

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 weeks later...

Thanks Tuanphan for the feedback!

I've tried adding the following to the css under the Design section and for whatever reason it's not changing the amount of space on the top of the div (either margin, or padding):

 

@media screen and (max-width:640px) {
    div#home-page {
       margin-top:0px;
       padding-top:0px;
      padding-left:0px;
      padding-right:0px;
    }
}

div#home-page {
   padding-top:7px;
   padding-left:0px;
   padding-right:0px;
}

Please see the attached screenshots.

Any ideas on how to get it to respond correctly? Is there a separate div for mobile?? 

Thanks

 

 

ss1.png

ss2.png

Link to comment

Use this code

/* destkop padding */
div#home-section .page-content {
    padding-top: 0;
}
/* mobile padding */
@media screen and (max-width:640px) {
div#block-yui_3_17_2_1_1585965744269_13769 {
    padding-top: 0 !important;
}
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.