当前位置:网站首页>Div horizontal layout aligned on both sides
Div horizontal layout aligned on both sides
2022-07-29 09:37:00 【Sabo】
Method 1
Parent container div Use position: relative;, Son div Use position:absolute; location , Pay attention to the margin
html
<div class="div-container">
<div class="div1">1</div>
<div class="div2">2</div>
</div>css
/* Method 1 */
.div-container {
margin: 10px 0;
padding: 10px;
width: 400px;
border: 2px solid #ccc;
position: relative;
}
.div1 {
width: 100px;
height: 50px;
border: 2px solid red;
}
.div2 {
width: 100px;
height: 50px;
border: 2px solid red;
position: absolute;
/* Margin setting */
right: 10px;
top: 10px;
} Parent container div Use display:flex; justify-content:space-between; that will do
html
<div class="div-container2">
<div class="div3">3</div>
<div class="div4">4</div>
</div>css
/* Method 2 */
.div-container2 {
margin: 10px 0;
padding: 10px;
width: 400px;
border: 2px solid #ccc;
display: flex;
justify-content: space-between;
}
.div3 {
width: 100px;
height: 50px;
border: 2px solid red;
}
.div4 {
width: 100px;
height: 50px;
border: 2px solid red;
}Method 3
Parent container div Use display: flex; Achieve horizontal arrangement , Son div Set the width to fill the space
html
<div class="div-container3">
<div class="div5">5</div>
<div class="div7"> placeholder div</div>
<div class="div6">6</div>
</div>css
/* Method 3 */
.div-container3 {
margin: 10px 0;
padding: 10px;
width: 400px;
border: 2px solid #ccc;
display: flex;
justify-content: space-between;
}
.div5 {
width: 100px;
height: 50px;
border: 2px solid red;
}
.div6 {
width: 100px;
height: 50px;
border: 2px solid red;
}
.div7 {
width: calc(100% - 100px - 100px);
height: 50px;
border: 1px solid #ccc;
}GitHub Full code link https://github.com/gywgithub/exercise01/blob/master/div-flex/index.html
边栏推荐
- Pyqt5 rapid development and practice 6.4 qboxlayout (box layout)
- Handwritten character recognition
- 远程连接windows版本服务器redis的配置文件设置
- Unity xchart3.0 basic usage quick start
- Unity 引导系统.点击目标物体后提示文字变色进入下一步
- Excel tool for generating database table structure
- How to change MySQL into Chinese
- dataframe.to_sql() 一次性插入过多报错
- First order traversal / second order traversal determines the approximate shape of the tree
- Evaluation index of machine learning classification model and implementation of sklearn code
猜你喜欢

AxureRP原型设计 快速开始

Opencv introductory basic learning

Cloud native management practice: business led Devops continuous delivery system

Configuration file settings for remote connection to Windows version server redis

Parameter initialization

核酸扫码登记体验有感(如何提高OCR的文字正确识别率)

Excel tool for generating database table structure

Handwritten character recognition

引入redis缓存出现的问题以及解决方式

网络安全(6)
随机推荐
数据库表结构生成excel工具
基于C语言模拟实现DFA识别字符串
How to export the old and new file names and locations to excel after file renaming
云原生管理实践:业务引领的DevOps持续交付体系
数仓项目踩坑记录与解决方法总结
node(二)
Pyqt5 rapid development and practice 6.4 qboxlayout (box layout)
深入浅出依赖注入及其在抖音直播中的应用
Basic part 2 of flowable
Qmainwindow details
当 update 修改数据与原数据相同时会被更新吗?
Use cpolar to publish raspberry pie web pages (improvement of cpolar tunnel)
Shutter -- use camera (continuously updating)
Network security (5)
How does alternates achieve high-performance publish and subscribe?
vector实现
PyQt5快速开发与实战 6.4 QBoxLayout(框布局)
远程连接windows版本服务器redis的配置文件设置
浅谈契约测试
附录2-一些简单的练习