zoukankan      html  css  js  c++  java
  • CSS中width,min-width和max-width之间的联系

    字面意思来看,width,min-width和max-width分别代表的是元素的宽度,最小宽度和最大宽度,那么他们之间有什么联系呢?

    <div class="container">
    </div>
    <style>
    .container {
        background-color: red;
        height: 100px;
         100px
    }
    </style>
    

    此时width为100px,显示结果如下图:

    100px

    .container { 
    background-color: red; 
    height: 100px; 
     100px; 
    max- 50px 
    } 

    此时显示max-50px,如下图所示:

    50px

    .container { 
    background-color: red; 
    height: 100px; 
     100px; 
    max- 150px 
    } 

    此时显示width:100px,如下图所示: 

    100px

    只设width和max-width时,谁值小显示谁。

    .container {
                background-color: red;
                height: 100px;
                 100px;
                min-120px;
            }

    此时显示min-120px如图:

    120px

      .container {
                background-color: red;
                height: 100px;
                 100px;
                min-20px;
            }

    此时显示width:100px;如图:

    100px

    只设width和min-width谁大显示谁。

    .container { 
    background-color: red; 
    height: 100px; 
     100px; 
    max- 50px; 
    min- 20px 
    } 

    此时显示50px,如下图所示: 

    50px

     .container { 
            background-color: red; 
    height: 100px; 
     100px; 
    max- 20px; 
    min- 50px 
    } 

    此时显示50px,如图:

    50px

     当 min-width和max-width小于width时,显示min和max中大的那个值。

    .container { 
    background-color: red; 
    height: 100px; 
     100px; 
    max- 150px; 
    min- 120px 
    } 

    此时显示min-width:120px;如图所示:

    120px

      .container { 
            background-color: red; 
    height: 100px; 
     100px; 
    max- 120px; 
    min- 150px 
    } 

    150px

    当min-width和max-wdith大于width时,显示min值。

    .container { 
    background-color: red; 
    height: 100px; 
     100px; 
    max- 150px; 
    min- 20px 
    } 

    此时显示100px,如图:

    100px

    .container { 
    background-color: red; 
    height: 100px; 
     100px; 
    max- 50px; 
    min- 120px 
    } 

    此时显示120px,如图:

     120px

     width和min谁大显示谁 

  • 相关阅读:
    [题解] P2513 [HAOI2009]逆序对数列
    [题解]洛谷P2709 小B的询问
    题解 P1944 最长括号匹配_NOI导刊2009提高(1)
    [题解]SP703 SERVICE
    Bzoj2427: [HAOI2010]软件安装
    【题解】UVA11362 Phone List
    【题解】P2922 [USACO08DEC]秘密消息Secret Message
    Tire树的学习
    【题解】P1171 售货员的难题
    计算机与编程资源教程汇总
  • 原文地址:https://www.cnblogs.com/colorful-paopao1/p/12617976.html
Copyright © 2011-2022 走看看