当前位置:网站首页>Margin left: -100% understanding in the Grail layout
Margin left: -100% understanding in the Grail layout
2022-07-03 07:17:00 【darabiuz】
If not set margin-left:100% Words , that left and right Elements will be squeezed into the second line because of insufficient space 
1. Yes margin Interpretation of values :
① Father son relationship :margin-left It refers to the left boundary between the child and the father ( If father has left padding value , It refers to this padding Line ) Distance of .margin-right It refers to the right boundary between the child and the father ( If father has right padding value , It refers to this padding Line ) Distance of .
② Brotherhood :margin-left It refers to my left boundary and my left brother's right boundary ( If brothers have right padding value , It refers to this padding Line ) Distance between .margin-right It refers to the distance between my right boundary and my right brother's left boundary ( If brothers have left padding value , It refers to this padding Line ).
The illustration :
2. about margin Understanding of taking negative values :
margin Negative values change the space occupied by elements . If you don't give him negative value , It must show on the second line , Because he occupies space .
This example ,left The width is 200px, When I set left Of margin-left by 200px, When it is the same width as him : That's what happens :
Obviously, we need to move more to the left , What is the distance of movement ?
center Width - left Width , That is, the distance marked in red in the figure below
We can conclude that : Just set up margin-left The negative value of is center The width of ( Initially moved 200px+ Distance to be moved ==center Width )
The second most intuitive understanding :
left The distance from the left of to the right of the parent element is equal to 200px
3. margin-left The meaning when the value of the attribute is a percentage :
When margin-left Percentage of value , Is the percentage relative to the width of the parent element
In the Grail layout, we set center The width is 100%, So the width of the parent element 100% Exactly equal to center Width , That's what we want 
边栏推荐
- Liang Ning: 30 lectures on brain map notes for growth thinking
- Architecture notes
- Crontab scheduled task
- Advanced API (use of file class)
- 《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
- 多个全局异常处理类,怎么规定执行顺序
- php artisan
- Advanced API (batch image Download & socket dialog)
- The underlying mechanism of advertising on websites
- SecureCRT password to cancel session recording
猜你喜欢
随机推荐
PAT甲级真题1166
php安装composer
4279. Cartesian tree
4EVERLAND:IPFS 上的 Web3 开发者中心,部署了超过 30,000 个 Dapp!
Liang Ning: 30 lectures on brain map notes for growth thinking
crontab定时任务
The education of a value investor
My 2020 summary "don't love the past, indulge in moving forward"
Centos切换安装mysql5.7和mysql8.0
MySQL syntax (basic)
Basic knowledge about SQL database
Mise en place d'un environnement de développement de fonctions personnalisées
[solved] win10 cannot find a solution to the local group policy editor
1. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
JMeter JSON extractor extracts two parameters at the same time
Pat grade a real problem 1166
Practical plug-ins in idea
II. D3.js draw a simple figure -- circle
[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
Summary of abnormal mechanism of interview








![[solved] sqlexception: invalid value for getint() - 'Tian Peng‘](/img/bf/f6310304d58d964b3d09a9d011ddb5.png)
![[HCAI] learning summary OSI model](/img/90/66505b22e32aa00b26886a9d5c5e4c.jpg)