Media Queries and min-width attribute in a browser

Media Queries....I'm not quite understanding min-width and the fact that it will work on a browser when you shrink it's size horizontally.   What is min-width actually a measure of.  Cause I feel like I would always be using max-width or even better an attribute called "width".

Just curious....I like for something to make sense in my head before using it regardless of whether it works
DaveKidAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
min-width means: Apply this style if the browser has at least a width of XXX

So lets say you want to make a <div> half the screen on larger screens but full on mobile.
Start by setting it for small screens
/* Set the default for small screens */
.myDiv {
   width: 100%;
}
/* Override the setting for screens 780px and larger */
@media (min-width: 780px) {
  .myDiv {
     width: 50%;
  }
}

Open in new window


So you can see from the above - we do a mobile first approach and override it with subsequent styles that come into effect at larger screen sizes.

You can read more about media queries here
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brandon LyonSenior Frontend DeveloperCommented:
Min-width is one of the many options for media queries. You can also use max-width for example (ie when the window has a maximum-width of XYZ px, apply these styles).

Here is some documentation with other forms of mediaqueries which can be used.

You can also combine multiple conditions into one media query. Ex: only apply some styles between yyy px and zzz px when the display orientation is horizontal...
0
DaveKidAuthor Commented:
Thanks.  The definition you gave at the beginning is what helped the most.  I completely get it now.
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.