Max-Width vs. Min-Width

后端 未结 7 1772
深忆病人
深忆病人 2020-12-04 05:10

Most of the tutorials I\'m reading on using Media Queries are demonstrating the use of min-width, but I\'m rarely seeing people using max-width.

7条回答
  •  春和景丽
    2020-12-04 05:49

    In short, min-width is a mobile 1st approach, max-width is a desktop 1st approach.

    Min-width is the minimum width at which a style will START to be applied. (Have to be ordered from smallest to largest to work properly, regular styles first). Put another way: If device width is greater than or equal to..., then apply some specific styles. With min-width, styles START and continue forever as long as min-width is met, and no max-width is specified.

    Max-width is the maximum width at which a style will continue to be applied. After that, the style will STOP being applied. (Have to be ordered from largest to smallest to work properly, regular styles first). Put another way: If device width is less than or equal to..., then apply specific styles. Styles STOP as soon as width greater than max-width is hit.

    Finally, It depends on how you want to implement. There is no ONE RIGHT solution as some may claim. In my opinion min-width works great when starting from scratch, but max-width often makes more sense to me when retrofitting an existing web site.

提交回复
热议问题