当前位置:网站首页>Method of realizing horizontal and vertical centering of unknown width and height elements
Method of realizing horizontal and vertical centering of unknown width and height elements
2022-07-19 03:32:00 【Drowned fish u】
1. Set element relative parent positioning position: absolute; left: 50% right: 50%; transform: translate(-50%, -50%)
<style> .f {
width: 300px; height: 300px; border: 1px solid #87ceeb; position: relative; } .c {
position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background-color: #87ceeb; } </style>
<body>
<div class="f">
<div class="c"> I want to center vertically </div>
</div>
<body>
2. Set the parent box to elastic box display: flex; justify-content: center; align-item: center;
Grid layout grid similar display: grid; justify-content: center; align-item: center;
<style> .f {
width: 300px; height: 300px; border: 1px solid #87ceeb; display: flex; justify-content: center; align-items: center; } .c {
background-color: #87ceeb; } </style>
<body>
<div class="f">
<div class="c"> I want to center vertically </div>
</div>
<body>
边栏推荐
- Rewrite equals why rewrite hashcode
- Paper reading: u-net++: redesigning skip connections to exploit multiscale features in image segmentation
- Ubuntu clear CUDA cache
- Multi table query - case exercise
- ncnn DataReader&Extractor&blob
- Can't access this website can't find DNS address DNS_ PROBE_ What about started?
- Install Net prompt "cannot establish a certificate chain to trust the root authority" (simple method with download address)
- Zabbix6.0 monitors Dell and IBM server hardware through Idrac and imm2
- Code demonstration of fcos face detection model in openvino
- Labelme starts normally, but cannot be opened
猜你喜欢

Display zabbix6.0 information using grafana8.5.2

Affine transformation implementation

Polynomial interpolation fitting (I)

ES6 learning notes - brother Ma at station B

leetcode 222. 完全二叉树的节点个数(必会)

Redis和其他数据库的比较

367. 有效的完全平方数(入门必会)

Chengxin University envi_ The second week of IDL experiment content: extract aod+ in all MODIS aerosol products for detailed analysis

Powertor500t reports an error 0x01806803
![Dqn theoretical basis and code implementation [pytoch + cartpole-v0]](/img/cf/32438e403544aa42e2fdd2e181327c.png)
Dqn theoretical basis and code implementation [pytoch + cartpole-v0]
随机推荐
oracle 关闭回收站
Visual analysis of ncnn param file and bin model
Monte Carlo based reinforcement learning method [with code implementation]
IEEE754 standard floating point format
MYSQL主从搭建
It's good to take more exercise
Polynomial interpolation fitting (II)
MySQL interview questions (2022)
ES6學習筆記——B站小馬哥
谷歌 Chrome 浏览器安装 PWA 应用将显示更多描述信息
Zabbix6.0 monitors Dell and IBM server hardware through Idrac and imm2
After 4 years of developing two-sided meituan, we finally lost: the interview question of volatile keyword function and principle
Configure high availability using virtual ip+kept
Theoretical basis of doubledqn and its code implementation [pytoch + pendulum-v0]
代理模式——B站动力节点
[MCU simulation] (XXI) dB (define byte) - define byte
While loop
Browser cannot open tensorboard
Leetcode: dynamic programming [basic problem solving]
JDBC connection to MySQL database