首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS框布局查询

CSS框布局查询
EN

Stack Overflow用户
提问于 2022-08-04 03:07:55
回答 1查看 39关注 0票数 0

我需要css样式的帮助。布局应如下所示。

  1. 标题块覆盖整个行,
  2. 第2行=>,两块高度相同,宽度为80%-20%,并排和第二块应该在垂直堆叠的内部有两个块。
  3. 第3排=>两块高度相同,共享50-50
  4. ,一个大标题

>

我试过像这样

代码语言:javascript
复制
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  height: 900px;
  position: absolute;
}
.cell {
  border: solid 3px black;
}
.cell-1 {
  width: 1500px;
  
}

.cell-2 {
height: 450px;
width: 20%;
}

.cell-3 {
height: 450px;
width: 20%;
}

.big-container {
display: fixed;
flex-direction: row;
flex-wrap: wrap;
position: relative;
}

.container-2 {
display: inline-block;
flex-direction: column;
flex-wrap: wrap;
height: 100px;
position: absolute;
}

.container-3 {
display: flex;
flex-direction: column;
flex-wrap: wrap;
margin-top: 1300px;
height: 700px;
position: absolute;
}

.cell-2-1 {
margin-right: 300px;
margin-top: 1000px;
text-align: center;
width: 100%
}

.cell-2-2 {
width: 50%;
width:700px;
}

.cell-2-3 {
width: 50%;
margin-left: 200px;
}
代码语言:javascript
复制
<div className="big-container">
                <div className="container-1">
                    <div className="cell cell-1">
                        <Component1 /> (row2-left block)
                    </div>
                    <div className="cell cell-2">
                        <Component2 /> (row2-left block)
                    </div>
                    <div className="cell cell-3">
                        <Component3 /> (row2-right-side bottom block)
                    </div>
                </div>


                <div className="container-3">
                    <div className='cell-2-2'>
                       <Component5 /> (row4-left block)
                    </div>
                    <div className='cell-2-3'>
                       <Component6 /> (row4-right block)
                    </div>
                </div>
            </div>

我以一种不正确的方式实现了它,比如根据到目前为止组件占用的空间,将.contain-3边距增加到1300 px。我想知道是否有更好更容易做到的

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-04 05:30:08

我想你找这样的东西很难搞清楚,因为你没有提供预期的产出。

代码语言:javascript
复制
body{
  padding: 0;
  margin: 0;
  height: 100vh;  
  Width: 100VW;
  background:#333;
}

.big-container{
  display:flex;
  flex-direction:column;
}

.heading-row , .big-heading{
  width:100%;
  background-color:yellow;
}

.row1 , .row2{
  height:400px;
  display:flex;
}

.row1 .box1{
  width:80%;
  height:100%;
  background:red;
}

.row1 .box2{
  width:20%;
  height:100%;
  background:blue;
  display:flex;
  flex-direction:column;
}

.row1 .box2 > *{
  height:50%;
  width:100%;
}

.row1 .box2 .verticle-box1{
  background-color:green;
}

.row1 .box2 .verticle-box2{
  background-color:pink;
}

.row2 > *{
  height:100%;
  width:50%;
}

.row2 .box1{
 background:orange;
}
.row2 .box2{
 background:purple;
}
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <div class="big-container">
    
    <div class="heading-row">
      <h1>Heading</h1>
    </div>
    
    <div class="row1">
      
      <div class="box1"></div>
      
      <div class="box2">
        
        <div class="verticle-box1"></div>
        <div class="verticle-box2"></div>
        
      </div>
      
    </div>
    
    <div class="row2">
      
      <div class="box1"></div>
      
      <div class="box2"></div>
      
    </div>
    
    <div class="big-heading">
       <h1>Heading</h1>
    </div>
    
  </div>
  
  
  
</body>
</html>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73229937

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档