当前位置:网站首页>Centering problem - the width and height of child elements are known
Centering problem - the width and height of child elements are known
2022-06-13 08:34:00 【Just one time】
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> In the middle </title>
<style> .box{
width: 400px; height: 400px; background-color: pink; /* Method 1 */ /* overflow: hidden; */ /* Method 2 */ /* padding: 100px 100px; box-sizing: border-box; */ /* Add... To the parent element padding Parent element converted to ie The box model */ /* Method 3 */ /* display: flex; justify-content: center; align-items: center; */ /* Method 4 */ /* position: relative; */ /* Set relative positioning The child element is positioned relative to the parent element */ /* Method 5 */ /* position: relative; */ /* Method 6 */ /* display: table-cell; text-align: center; vertical-align: middle; */ /* Convert to table item */ } .box1{
width: 200px; height: 200px; background-color: #00BFFF; /* Method 1 */ /* margin: 100px 100px; */ /* Add to child elements margin Parent element overflow:hidden */ /* Method 4 */ /* position: absolute; left: 100px; top: 100px; */ /* Set relative positioning The child element is positioned relative to the parent element */ /* Method 5 */ /* position: absolute; top: 50%; left: 50%; margin-top: -100px; margin-left: -100px; */ /* Set relative positioning The child element is positioned half as high as the parent element The child element is positioned half the width of the parent element The last child element is offset to the left -100px(-100px Express ) */ /* Method 6 */ /* display: inline-block; */ /* Method 7 */ transform: translate(100px,100px); } </style>
</head>
<body>
<!-- The child element is inside the parent element Child elements are centered horizontally and vertically -->
<div class="box">
<div class="box1">
</div>
</div>
</body>
</html>
边栏推荐
- [game theory complete information static game] Application of Nash equilibrium
- The method of SolidWorks modifying text font in engineering drawing
- Three methods to make the scroll bar of div automatically scroll to the bottom
- HCIP_ OSPF irregular area
- Input prohibit copy and paste
- redis. exceptions. ConnectionError: Error 111 connecting to 172.16.8.128:6379. Connection refused.
- JS - for cycle case: Horse grain
- Penetration problem (main directory, password explosion, database uploading Trojan horse)
- JS to download files in batches
- Phpexcel 10008 error resolution
猜你喜欢
Svg text stroke effect
Wechat upload picture material interface
How about a well-known food material distribution information management system?
JS - print 99 multiplication table of the for cycle case
JS - set countdown for Date object case
Container concept and cloud native
从零开始-实现JpetStore网站-1-建立项目框架以及项目介绍
What software can be used to solve the problems faced by the auto parts industry
VS安装VAssistX插件导致WPF-XAML文件输入中文出现乱码问题解决方案
Redis subscribe connection timeout interrupt problem solution
随机推荐
Dest0g3 520迎新赛
Svg text stroke effect
Which is the stronger fresh food distribution and sorting management system?
Leetcode- sort arrays by parity
Notes on MySQL transaction not automatically submitting
Redis subscribe connection timeout interrupt problem solution
SQL injection question type (manual injection +sqlmap)
JS to download files in batches
Microservice system architecture construction I: Environment Construction
Verify the word limit of textarea input box. Only prompt but no submission limit
[virt manager] remote management the problem of the floating mouse when starting the virtual machine
Journal d'acquisition du faisceau de fichiers à Elk
微服务系统架构搭建一:环境搭建
JS - for cycle case: Horse grain
How to dynamically delete data rows in a table through JS (keep the head)
[virt-manager]远程管理启动虚拟机时,鼠标飘逸的问题
How to install the bdtab (BD) new tab plug-in in edge browser (Graphic tutorial)
DHCP principle and configuration
Buuctf web (VI)
MySQL parsing serialized fields