Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flex-grow & flex-shrink & flex-basis #20

Open
bigggge opened this issue Jun 14, 2018 · 0 comments
Open

flex-grow & flex-shrink & flex-basis #20

bigggge opened this issue Jun 14, 2018 · 0 comments

Comments

@bigggge
Copy link
Member

bigggge commented Jun 14, 2018

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
      .main {
        width: 600px;
        display: flex;
      }

      .main div {
        height: 50px
      }
    </style>
  </head>
  <body>
    <div class="main">
      <!--剩余空间600-100=500px-->
      <!--500/6-->
      <div style="background: green;flex-grow: 1;"></div>
      <!--500/6*2+100-->
      <div style="background: indianred;flex-basis: 100px;flex-grow: 2;"></div>
      <!--500/6*3-->
      <div style="background: yellowgreen;flex-grow: 3;"></div>
    </div>

    <div class="main">
      <!--600-(300+100+250)=-50px-->
      <!--总权重 300*1+100*2+250*3=1250-->
      <!--(300*1/1250)*50=12   300-12=288px-->
      <div style="background: green;flex-basis: 300px;flex-shrink: 1;"></div>
      <!--(100*2/1250)*50=8    100-8=92px-->
      <div style="background: indianred;flex-basis: 100px;flex-shrink: 2;"></div>
      <!--(250*3/1250)*50=30   250-30=220px-->
      <div style="background: yellowgreen;flex-basis: 250px;flex-shrink: 3;"></div>
    </div>

  </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant