-3

as usually happens I have responsive navigation div. So I want to write CSS for it to have position fixed only on mobile devices. How do I do it ?

nika
  • 59
  • 1
  • 8
  • Welcome to Stack Overflow! Questions seeking code help must include the shortest code necessary to reproduce it **in the question itself**. See [**How to create a Minimal, Complete, and Verifiable example**](http://stackoverflow.com/help/mcve) – Paulie_D Jan 21 '16 at 16:21

2 Answers2

0

You can use CSS Media Query.

Here You can find more information: Using media query

An example for your case:

@media only screen and (max-width: 40em) and (orientation: portrait){ // your code}
M1L0
  • 71
  • 9
0

I can't really give an example because you have been extremely vague in your question, but you can use css media queries to change styles for mobiles. You can set the maximum width for which to apply those styles to, meaning that anything smaller than that width will use those styles. (There are also loads of other options for media queries like aspect ratio; you can see more of them here, as well as how to use them).

Here is a very basic example of a media query you can use:

@media only screen and (min-width: 480px) {
    /* Styles here */
}

You can read more about them at these sites:

  1. https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
  2. Common CSS Media Queries Break Points
  3. https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
  4. https://responsivedesign.is/articles/why-you-dont-need-device-specific-breakpoints

[There are many more, just google it and you will find countless tutorials and examples.]

Community
  • 1
  • 1
M. Salman Khan
  • 608
  • 1
  • 6
  • 16