11

I just finished creating my website but now I have found a failure. My problem is that my website looks totally nice on the PC. But if I go and look at it from my mobile phone, the spaces between certain images etc. are a great deal too much...

So my question is, how can I create some CSS codes who are only affecting the mobile devices and maybe tablets?

Is there a way?

serv-inc
  • 35,772
  • 9
  • 166
  • 188
Jan
  • 277
  • 1
  • 6
  • 16

3 Answers3

15

CSS has feature called media queries. From the MDN link:

Media queries, added in CSS3, let the presentation of content be tailored to a specific range of output devices without having to change the content itself

For example:

div {
    background: black;
}

@media (max-width: 1000px) {
    div {
        background: yellow;
    }
}

The background color of this div will be yellow on screen under 1000px width like in the example provided.

Michael M.
  • 10,486
  • 9
  • 18
  • 34
Eyal Cohen
  • 1,188
  • 2
  • 15
  • 27
4

You can use media-queries for different screen resolutions. Example:

#image img {
    width:375px;
}

@media screen and (min-width: 1366px) {
    #image img {width:375px;}
}
Aiq0
  • 306
  • 1
  • 11
  • 1
    This answer would be more helpful (and would score higher) with a little more information. Could you explain a little further? Which is which? Any related links? thanks! ([answer]) – ashleedawg Jan 06 '19 at 09:19
2

Read and understand about Media Queries

You will be able to adjust the css of certain media sizes of your website.

Joseph Vu
  • 56
  • 4