GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [css] 第127天 说说你对min-width和max-width的理解,它们有什么运用场景? · Issue #1093 · haizlin/fe-interview

[css] 第127天 说说你对min-width和max-width的理解,它们有什么运用场景? #1093

New issue
Copy link
New issue
Copy link
Open
Open
[css] 第127天 说说你对min-width和max-width的理解,它们有什么运用场景?#1093
Copy link
Labels
csscss

Description

@haizhilin2013
haizhilin2013
opened on Aug 20, 2019
Issue body actions

第127天 说说你对min-width和max-width的理解,它们有什么运用场景?

Activity

  1. haizhilin2013
    added
    csscss
    on Aug 20, 2019
  2. LinStan commented on Aug 21, 2019

    @LinStan
    LinStan
    on Aug 21, 2019
    More actions

    min-width和max-width可以使得自适应布局保持一个基本的样式。
    用于多列布局时候,可以保证某几列的布局保持在一定的范围内。
    比较常见的应用应该是网站首页的三栏布局类型,一般是两边的侧边栏会设定一个最大最小宽度,中间为主栏,这样不管如何缩放都能突出主栏,且侧边栏也不会缩太小影响观感

  3. NicholasBaiYa commented on Aug 21, 2019

    @NicholasBaiYa
    NicholasBaiYa
    on Aug 21, 2019
    More actions

    min-width: 最小宽度。
    max-width: 最大宽度。
    因为我的主要业务在移动端,所以基本没用过。不过min-height和max-height使用的比较多。
    当页面的需要撑起整个屏幕的时候和弹框最高不能超过屏幕的60%

    min-height: 100vh;
    max-height: 60vh
  4. xxf1996 commented on Aug 21, 2019

    @xxf1996
    xxf1996
    on Aug 21, 2019
    More actions
    • min-width:设定元素的最小宽度,可以阻止元素的宽度小于该值;
    • max-width:设定元素的最大宽度,可以阻止元素的宽度大于该值;

    这两个属性多用于自适应宽度布局中,希望某些元素的宽度不能小于或大于某个宽度,以免造成难看的布局;如:表格自适应宽度时,当屏幕宽度较小,某一列的内容过多时,就会出现“一柱擎天”的现象,此时可以设置该列的min-width来避免这种情况。

  5. EragonBubble commented on Aug 21, 2019

    @EragonBubble
    EragonBubble
    on Aug 21, 2019
    More actions

    min-width 最小宽度;
    max-width 最大宽度。

    在自适应的布局中用到,当一个dom元素的宽度不确定时,可以设定这个宽度的变化范围。

  6. ferrisBreeze commented on Aug 23, 2019

    @ferrisBreeze
    ferrisBreeze
    on Aug 23, 2019
    More actions

    搭楼再补充几个我常见的几个应用场景

    1. 在线客服对话时的聊天框对话记录(类似微信聊天这种)
    2. 详情介绍图文混排中的image图片,避免中间有过大或者过小的图片影响浏览体验
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    csscss

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.