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

[css] 第44天 手写一个满屏品字布局的方案 #166

Open
haizhilin2013 opened this issue May 29, 2019 · 8 comments
Open

[css] 第44天 手写一个满屏品字布局的方案 #166

haizhilin2013 opened this issue May 29, 2019 · 8 comments
Labels
css css

Comments

@haizhilin2013
Copy link
Collaborator

第44天 手写一个满屏品字布局的方案

@haizhilin2013 haizhilin2013 added the css css label May 29, 2019
@tzjoke
Copy link

tzjoke commented May 31, 2019

整体100%高度,上面50高度margin auto居中,下面50%高度俩float一半宽度。。应该符合题意把

@DingkeXue
Copy link

flex布局

@zhuyuedlut
Copy link

用grid布局是否好点

@seho-dev
Copy link

<title>Parcel Sandbox</title> <style> .box { width: 100%; justify-content: center; display: flex;
		flex-wrap: wrap;
	}
	.top {
		flex: 50px 0 0;
        width: 100px;
        height: 100px;
        background: red;
        flex-grow: 3;
        font-size: 18px;
        color: #fff;
        text-align: center;
	}
	.bottom {
        width: 100%;
        
		display: flex;
	}
    .bottom-first {
        width: 50%;
        background: blue;
    }
    .bottom-second{
        width: 50%;
        background: orange;
    }
</style>
top
first
second

@ipadthree
Copy link

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta charset="UTF-8">
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <article class="container">
            <div class="firstRow">
                <div class="item"></div>
            </div>
            <div class="secondRow">
                <div class="item"></div>
                <div class="item"></div>
            </div>
        </article>
    </body>
</html>
//style.css
html, body{
    height: 100%;
    margin: 0;
    padding: 0;
}
 
.container {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    width: 100%;
    height: 100%;
}

.firstRow, .secondRow {
    width: 100%;
    height: 30%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    margin: 10px 0;
}

.item {
    background-color: red;
    width: 40%;
    height: 100%;
    margin: 0 auto;
    border-radius: 10%;
}

@kruzabc
Copy link

kruzabc commented Jan 2, 2020

两行 ,每行做flex布局

@blueRoach
Copy link

blueRoach commented Jul 21, 2020

**flex**
html, body{
  margin: 0;
  padding: 0;
  height: 100%;
}
.div1{
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  align-items: stretch;
  height: 100%;
  background-color: #f2f2f2;
}
.div1 > div{
  width: 50%;
  height: 50%;
}
.div2{
  margin: 0 25%;
  background-color: yellow;
}
.div3{
  background-color: blanchedalmond;
}
.div4{
  background-color: blueviolet;
}
</style>

<style>
**inline-block**
html, body{
  margin: 0;
  padding: 0;
  height: 100%;
}
.div1{
  height: 100%;
  background-color: #f2f2f2;
  font-size: 0;
}
.div1 > div{
  width: 50%;
  height: 50%;
}
.div2{
  margin: 0 auto;
  background-color: yellow;
}
.div3{
  display: inline-block;
  background-color: blanchedalmond;
}
.div4{
  display: inline-block;
  background-color: blueviolet;
}
</style>

<body>
  <div class="div1">
    <div class="div2"></div>
    <div class="div3"></div>
    <div class="div4"></div>
  </div>
</body>

@cinsyk
Copy link

cinsyk commented Sep 19, 2020

  • 标准流
<body>
    <div class="top"><div>
    <div class="bottom">
        <div class="left"><div>
        <div class="right"><div>
    <div>
</body>
.top {
    width:50%;
    marign:auto;
}
.bottom {
    font-size:0;
}
.bottom div {
    display:inline-block
    width:50%;
}
  • 浮动布局
<body>
    <div class="top"><div>
    <div class="bottom">
        <div class="left"><div>
        <div class="right"><div>
    <div>
</body>
.top {
    width:50%;
    height:50%;
    marign:auto;
}
.bottom {
    height:50%;
    overflow:hidden
}
.bottom div {
    float:left;
    width:50%;
}
  • flex布局
<body>
    <div class="top"><div>
    <div class="bottom">
        <div class="left"><div>
        <div class="right"><div>
    <div>
</body>
.top {
    width:50%;
    height:50%;
    marign:auto;
}
.bottom {
    display:flex;
    height:50%;
}
.bottom div {
    flex:1;
    height:100%;
}
  • grid布局
<body>
    <div class="top"><div>
    <div class="left"><div>
    <div class="right"><div>
</body>
body {
    display:grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
.top {
    grid-column-start: 1;
    grid-column-end: 3;
}

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

No branches or pull requests

9 participants