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

【Q306】如何实现左右固定,中间自适应布局 #308

Open
shfshanyue opened this issue Jun 2, 2020 · 5 comments
Open

【Q306】如何实现左右固定,中间自适应布局 #308

shfshanyue opened this issue Jun 2, 2020 · 5 comments
Labels

Comments

@shfshanyue
Copy link
Owner

No description provided.

@shfshanyue shfshanyue added the css label Jun 2, 2020
@shfshanyue
Copy link
Owner Author

可以参考 【Q017】css 如何实现左侧固定300px,右侧自适应的布局

.container
  .left
  .main
  .right
.container {
  display: flex;
}

.left {
  flex-basis: 300px;
  flex-shrink: 0;
}

.right {
  flex-basis: 300px;
  flex-shrink: 0;
}

.main {
  flex-grow: 1;
}

@Innocentw
Copy link

Innocentw commented Jul 30, 2020

.box {
display: flex
}


.left,.right {
width: 300px
}

.center {
flex: 1
}

@linlai163
Copy link

以前还要用圣杯和双飞翼,现在都直接 flex 了。

@Lonely-bear
Copy link

 <div class="container">
        <div class="left"></div>
        <div class="main"></div>
        <div class="right"></div>
  </div>
<style>
    /* grid布局 */
    
    .container {
        height: 20rem;
        margin: 2rem;
        background-color: #eeeeee;
        display: grid;
        grid-template-columns: 300px 1fr 300px;
    }
   
    .left {
        height: 100%;
        border: 1px solid black;
    }
    
    .main {
        height: 100%;
    }
    
    .right {
        height: 100%;
        border: 1px solid;
    }
</style>

@YanCoeder1
Copy link

楼上应该去掉height

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants