0

How can I create a vertical navigation bar for smartphones and a horizontal navigation bar for desktops?

I need a navigation bar for this example: https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_navbar_dropdown

2 Answers 2

1

You can give any element completely different styles at different screen sizes. Just use media queries:

@media (max-width: 768px /* Styles for 768px screen size and smaller */) {
   .element {
      background: red;
   }
}

@media (min-width: 768px /* Styles for 769px screen size and larger */) {
   .element {
      background: blue;
   }
}

Here's a helpful link: https://www.w3schools.com/cssref/css3_pr_mediaquery.asp

Sign up to request clarification or add additional context in comments.

Comments

0

Use media queries. With these you define a break point. Within each break point you can assign different css rules to your divs etc.

https://www.w3schools.com/css/css_rwd_mediaqueries.asp

With this example you can simply change width to 100% to get the desired effect. But do this in a media query at your required break point and that way you have two + styles depending on screen size.

example css

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.