Comments (6)
绝对定位 position: absolute 限定宽高 这个要给父元素添加相对定位position:relative,要不然都跑出去了,flex好像没啥作用
from you-need-to-know-css.
我想知道top: calc(50% - 16px); left: calc(50% - 72px); 为啥是减去16px 和72px呢,有什么原理吗
from you-need-to-know-css.
我想知道top: calc(50% - 16px); left: calc(50% - 72px); 为啥是减去16px 和72px呢,有什么原理吗
这里减去的是元素自身宽/高的一半
from you-need-to-know-css.
绝对定位 position: absolute 限定宽高 这个要给父元素添加相对定位position:relative,要不然都跑出去了,flex好像没啥作用
是需要加relative的。绝对定位元素相对于最近的非 static 祖先元素定位。当这样的祖先元素不存在时,则相对于ICB(inital container block, 初始包含块)
from you-need-to-know-css.
这是在移动端经常使用的方式
display: flex no limit to width & height
main {
width:100%;
height:100%;
display: flex;
justify-content: center;
align-items: center;
min-height: 152px;
}
main > div {
flex: 0 1 auto;
background: #b4a078;
color: white;
padding: .3em 1em .5em;
border-radius: 3px;
box-shadow: 0 0 0.5em #b4a078;
}
<main>
<div>Center me, please!</div>
</main>
from you-need-to-know-css.
定位居中,应该在父元素加一个position:absolute;更加容易懂吧!
from you-need-to-know-css.
Related Issues (20)
- 提示气泡 HOT 1
- 圣杯布局 HOT 4
- 双飞翼布局 HOT 2
- 类订单布局 HOT 1
- 1px 线/边 HOT 2
- 插入换行
- 弹跳效果 HOT 1
- Flex布局 HOT 4
- Im so happy to read it HOT 1
- progress 中 的动画 panoramic 是不是忘了加上去? HOT 2
- 自定义变量
- 有趣的项目 HOT 4
- 文本截断 HOT 2
- 常用代码片段
- 自定义开关按钮Switch HOT 2
- On hover fade image and show text
- 是star,不是start
- 大量图片拼写文字效果
- 官网挂了 HOT 1
- flex小节错误 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from you-need-to-know-css.