Giter Club home page Giter Club logo

Comments (6)

shfshanyue avatar shfshanyue commented on May 14, 2024 2

代码见 左侧固定,右侧自适应 - Codepen

使用 flex 布局,左侧 300px,右侧 flex-grow: 1pug 代码及 css 代码示例如下

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

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

.main {
  flex-grow: 1;
}

如果只使用 Grid 布局,则代码会更加简单,只需要控制容器的 CSS 属性

.container {
  display: grid;
  grid-template-columns: 300px 1fr;
}

from daily-question.

Uwah avatar Uwah commented on May 14, 2024 1

左侧300px;右侧flex: 1; 采用flex的固比模型

from daily-question.

zhaochongzi avatar zhaochongzi commented on May 14, 2024

css---
.box{
width:100%;;
height:100%;
display:flex;
}
.one{
width:300px;
height:300px;
background-color: #afa;
}
.two{
flex:1;
height:300px;
background-color: #ae5aca;
}
html----

12312313
123

from daily-question.

bohancen avatar bohancen commented on May 14, 2024

使用calc方法
.left{width:330px;}
.right{width: calc(100% - 330px)}

from daily-question.

szc-sun avatar szc-sun commented on May 14, 2024

圣杯布局吧, float也可以,不过很少用了
.container{padding-left: 300px;}
.left,.main { float: left;position: relative;}
.left{width: 300px;right: 300px;margin-left: -100%}
.main{width: 100%;}

from daily-question.

wuzqZZZ avatar wuzqZZZ commented on May 14, 2024

浮动+BFC

<div class="box">
  <div class="box1"></div>
  <div class="box2"></div>
</div>
.box {
    height: 400px;
    background-color: skyblue;
}
.box1 {
    float: left;
    width: 300px;
    height: 200px;
    background-color: red;
} 
.box2 {
    height: 200px;
    background-color: blue;
   overflow:hidden;
}

from daily-question.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.