一对一直播系统开发,页面布局设计有很多可选项

居中布局

水平居中

1、text-align:center

复制代码
<style>
  .container {
    text-align: center;
  }
  .children {
    display: inline-block;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

2、margin: 0 auto

复制代码
<style>
  .children {
    width: 100px;
    margin: 0 auto;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

3、flex

复制代码
<style>
  .container {
    display: flex;
    justify-content: center;
  }
  .children {
    width: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

4、absolute+transform

复制代码
<style>
  .children {
    position: absolute;
    left: 50%;
    transform: translate(-50%, 0);
    width: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

垂直居中

1、line-height

复制代码
<style>
  .container {
    height: 500px;
    line-height: 500px;
    background: green;
  }
  .children {
    display: inline;
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

2、flex

复制代码
<style>
  .container {
    display: flex;
    align-items: center;
    height: 500px;
    background:green;
  }
  .children {
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

3、absolute+transform

复制代码
<style>
  .container {
    position: relative;
    height: 500px;
    background:green;
  }
  .children {
    position: absolute;
    top: 50%;
    transform: translate(0, -50%);
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

4、table cell

复制代码
<style>
  .container {
    display: table-cell;
    vertical-align: middle;
    height: 500px;
    background:green;
  }
  .children {
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

5、margin

复制代码
<style>
  .container {
    position: relative;
    height: 500px;
    background:green;
  }
  .children {
    position: absolute;
    top:0;
    bottom: 0;
    margin: auto 0;
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

水平垂直居中

1、absolute+transform

复制代码
<style>
  .container {
    position: relative;
    width: 100%;
    height: 500px;
    background:green;
  }
  .children {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

2、flex

复制代码
<style>
  .container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 500px;
    background:green;
  }
  .children {
    width: 100px;
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

3、margin

复制代码
<style>
  .container {
    position: relative;
    width: 100%;
    height: 500px;
    background:green;
  }
  .children {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;
    width: 100px;
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

4、table-cell

复制代码
<style>
  .container {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    width: 100vw;
    height: 500px;
    background:green;
  }
  .children {
    display: inline-block;
    width: 100px;
    height: 100px;
    background: blue;
  }
</style>
<body>
  <div class="container">
    <div class="children">children</div>
  </div>
</body>
复制代码

 

多列布局

一列定宽,一列自适应

1、float+margin

复制代码
<style>
  .left {
    float: left;
    width: 100px;
    background:green;
  }
  .right {
    margin-left: 100px;
    background: blue;
  }
</style>
<body>
  <div class="left">
    left
  </div>
  <div class="right">right</div>
</body>
复制代码

 

2、float+overflow

复制代码
<style>
  .left {
    float: left;
    width: 100px;
    background:green;
  }
  .right {
    overflow: hidden;
    background: blue;
  }
</style>
<body>
  <div class="left">
    left
  </div>
  <div class="right">right</div>
</body>
复制代码

 

3、table

复制代码
<style>
  .parent {
    display: table;
    width: 100%;
  }
  .left {
    display: table-cell;
    width: 100px;
    background:green;
  }
  .right {
    display: table-cell;
    background: blue;
  }
</style>
<body>
  <div class="parent">
    <div class="left">left</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

4、flex

复制代码
<style>
  .parent {
    display: flex;
    width: 100%;
  }
  .left {
    width: 100px;
    background:green;
  }
  .right {
    flex: 1;
    background: blue;
  }
</style>
<body>
  <div class="parent">
    <div class="left">left</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

多列定宽,一列自适应

1、float+overflow

复制代码
<style>
  .parent {
    width: 100%;
  }
  .left-one, .left-two {
    float: left;
    width: 100px;
  }
  .left-one {
    background: green;
  }
  .left-two {
    background: yellow;
  }
  .right {
    overflow: hidden;
    background: blue;
  }
</style>
<body>
  <div class="parent">
    <div class="left-one">left-one</div>
    <div class="left-two">left-two</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

2、table

复制代码
<style>
  .parent {
    display: table;
    width: 100%;
  }
  .left-one, .left-two {
    display: table-cell;
    width: 100px;
  }
  .left-one {
    background: green;
  }
  .left-two {
    background: yellow;
  }
  .right {
    display: table-cell;
    background: blue;
  }
</style>
<body>
  <div class="parent">
    <div class="left-one">left-one</div>
    <div class="left-two">left-two</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

3、flex

复制代码
<style>
  .parent {
    display: flex;
    width: 100%;
  }
  .left-one, .left-two {
    width: 100px;
  }
  .left-one {
    background: green;
  }
  .left-two {
    background: yellow;
  }
  .right {
    flex: 1;
    background: blue;
  }
</style>
<body>
  <div class="parent">
    <div class="left-one">left-one</div>
    <div class="left-two">left-two</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

三栏(左右栏固定宽度中间自适应)

1、绝对定位

复制代码
<style>
  .container div {
    position: absolute;
    min-height: 200px;
  }
  .left {
    left: 0;
    width: 300px;
    background: yellow;
  }
  .center {
    left: 300px;
    right: 300px;
    background: gray;
  }
  .right {
    right: 0;
    width: 300px;
    background: green;
  }
</style>
<body>
  <div class="container">
    <div class="left">left</div>
    <div class="center">center</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

2、float

复制代码
<style>
  .container div {
    min-height: 200px;
  }
  .left {
    float: left;
    width: 300px;
    background: yellow;
  }
  .center {
    background: gray;
  }
  .right {
    float: right;
    width: 300px;
    background: green;
  }
</style>
<body>
  <div class="container">
    <div class="left">left</div>
    <div class="right">right</div>
    <div class="center">center</div>
    
    <!--<div class="left">left</div>-->
    <!--<div class="center">center</div>-->
    <!--<div class="right">right</div>-->
    
  </div>
</body>
复制代码

 

3、flex

复制代码
<style>
  .container {
    display: flex;
    min-height: 200px;
  }
  .left {
    width: 300px;
    background: yellow;
  }
  .center {
    flex: 1;
    background: gray;
  }
  .right {
    width: 300px;
    background: green;
  }
</style>
<body>
  <div class="container">
    <div class="left">left</div>
    <div class="center">center</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

4、表格布局

复制代码
<style>
  .container {
    width:100%;
    display: table;
    min-height: 200px;
  }
  .container div {
    display: table-cell;
  }
  .left {
    width: 300px;
    background: yellow;
  }
  .center {
    background: gray;
  }
  .right {
    width: 300px;
    background: green;
  }
</style>
<body>
  <div class="container">
    <div class="left">left</div>
    <div class="center">center</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

5、网格布局

复制代码
<style>
  .container {
    width:100%;
    display: grid;
    grid-template-rows: 200px;
    grid-template-columns: 300px auto 300px;
  }
  .left {
    background: yellow;
  }
  .center {
    background: gray;
  }
  .right {
    background: green;
  }
</style>
<body>
  <div class="container">
    <div class="left">left</div>
    <div class="center">center</div>
    <div class="right">right</div>
  </div>
</body>
复制代码

 

等分

1、float

复制代码
<style>
  .parent {
    width: 100%;
  }
  .one, .two, .three, .four{
    float: left;
    width: 25%;
  }
  .one {
    background: green;
  }
  .two {
    background: yellow;
  }
  .three {
    background: blue;
  }
  .four {
    background: red;
  }
</style>
<body>
  <div class="parent">
    <div class="one">one</div>
    <div class="two">two</div>
    <div class="three">three</div>
    <div class="four">four</div>
  </div>
</body>
复制代码

 

2、table

复制代码
<style>
  .parent {
    display: table;
    width: 100%;
  }
  .one, .two, .three, .four{
    width: 25%;
    display: table-cell;
  }
  .one {
    background: green;
  }
  .two {
    background: yellow;
  }
  .three {
    background: blue;
  }
  .four {
    background: red;
  }
</style>
<body>
  <div class="parent">
    <div class="one">one</div>
    <div class="two">two</div>
    <div class="three">three</div>
    <div class="four">four</div>
  </div>
</body>
复制代码

 

3、flex

复制代码
<style>
  .parent {
    display: flex;
    width: 100%;
  }
  .one, .two, .three, .four{
    flex: 1;
  }
  .one {
    background: green;
  }
  .two {
    background: yellow;
  }
  .three {
    background: blue;
  }
  .four {
    background: red;
  }
</style>
<body>
  <div class="parent">
    <div class="one">one</div>
    <div class="two">two</div>
    <div class="three">three</div>
    <div class="four">four</div>
  </div>
</body>
复制代码

 

圣杯布局

复制代码
<style>
  .header {
    background: green;
    height: 50px;
  }
  .wrapper {
    height: 200px;
    display: flex;
  }
  .wrapper .left {
    width: 100px;
    background: yellow;
  }
  .wrapper .main {
    flex: 1;
    background: blue;
  }
  .wrapper .right {
    width: 100px;
    background: red;
  }
  .footer {
    height: 50px;
    background: gray;
  }
</style>
<body>
  <div class="container">
    <div class="header">header</div>
    <div class="wrapper">
      <div class="left">left</div>
      <div class="main">main</div>
      <div class="right">right</div>
    </div>
    <div class="footer">footer</div>
  </div>
</body>
复制代码

 

以上就是一对一直播系统开发,页面布局设计有很多可选项, 更多内容欢迎关注之后的文章

 

posted @   云豹科技-苏凌霄  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2023-05-11 直播网站程序源码,【openpyxl】只读模式、只写模式
2023-05-11 直播系统搭建,插入图片、删除图片、设置图片大小
2023-05-11 成品直播源码推荐,js点击让窗口抖动动画效果
2022-05-11 在线直播系统源码,Android开发之自带阴影效果的shape
2022-05-11 小视频源码,自定义倒计时,结束后进入重新发送界面
2022-05-11 短视频系统源码,几种常见的单例模式
点击右上角即可分享
微信分享提示