首页 > 其他分享 >margin:auto position: absolute 居中 对应在 w3c规范 中的描述

margin:auto position: absolute 居中 对应在 w3c规范 中的描述

时间:2023-04-23 14:34:48浏览次数:56  
标签:w3c elements bottom auto top height position margin

https://www.w3.org/TR/CSS2/visudet.html

 

10.6 Calculating heights and margins

For calculating the values of 'top''margin-top''height''margin-bottom', and 'bottom' a distinction must be made between various kinds of boxes:

  1. inline, non-replaced elements
  2. inline, replaced elements
  3. block-level, non-replaced elements in normal flow
  4. block-level, replaced elements in normal flow
  5. floating, non-replaced elements
  6. floating, replaced elements
  7. absolutely positioned, non-replaced elements
  8. absolutely positioned, replaced elements
  9. 'inline-block', non-replaced elements in normal flow
  10. 'inline-block', replaced elements in normal flow

这里适用于7 8

绝对定位,非替换元素

绝对定位,替换元素

 

10.6.4 Absolutely positioned, non-replaced elements

For the purposes of this section and the next, the term "static position" (of an element) refers, roughly, to the position an element would have had in the normal flow. More precisely, the static position for 'top' is the distance from the top edge of the containing block to the top margin edge of a hypothetical box that would have been the first box of the element if its specified 'position' value had been 'static' and its specified 'float' had been 'none' and its specified 'clear' had been 'none'. (Note that due to the rules in section 9.7 this might require also assuming a different computed value for 'display'.) The value is negative if the hypothetical box is above the containing block.

But rather than actually calculating the dimensions of that hypothetical box, user agents are free to make a guess at its probable position.

For the purposes of calculating the static position, the containing block of fixed positioned elements is the initial containing block instead of the viewport.

For absolutely positioned elements, the used values of the vertical dimensions must satisfy this constraint:

'top' + 'margin-top' + 'border-top-width' + 'padding-top' + 'height' + 'padding-bottom' + 'border-bottom-width' + 'margin-bottom' + 'bottom' = height of containing block

If all three of 'top', 'height', and 'bottom' are auto, set 'top' to the static position and apply rule number three below.

If none of the three are 'auto': If both 'margin-top' and 'margin-bottom' are 'auto', solve the equation under the extra constraint that the two margins get equal values.

如果这三个(top', 'height', and 'bottom')都不是“auto”:如果“margin-top”和“margin-bottom”都是“auto”,则在两个边距相等的额外约束下求解方程。

 

If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value. If the values are over-constrained, ignore the value for 'bottom' and solve for that value.

Otherwise, pick the one of the following six rules that applies.

  1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then the height is based on the content per 10.6.7, set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'top'
  2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then set 'top' to the static position, set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom'
  3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', then the height is based on the content per 10.6.7, set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom'
  4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', then set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'top'
  5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', then 'auto' values for 'margin-top' and 'margin-bottom' are set to 0 and solve for 'height'
  6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', then set 'auto' values for 'margin-top' and 'margin-bottom' to 0 and solve for 'bottom'

 

标签:w3c,elements,bottom,auto,top,height,position,margin
From: https://www.cnblogs.com/hhdom/p/17346461.html

相关文章

  • Adobe Photoshop 2023(MAC+Windows) +AI插件auto Photoshop stable diffusion plugin
    Adobe图像处理软件Photoshop2023正式版(24.1.1)2023年01月版发布。AdobePhotoshop2023破解版(简称PS)是一款全球流行的专业图像处理软件及照片和设计软件。AdobePhotoshop中文破解版是AdobeCreativeCloud创意云桌面程序中心的图形设计软件热门产品,它是平面设计领域和数......
  • uiautomator2+app ui自动化用例报错截图pytest_runtest_makereport
    pytest提供了pytest_runtest_makereport这个方法,可以捕获用例的执行情况。根据官方提供的示例,在conftest.py文件中添加如下代码就可以捕获每个用例的执行结果。那么pytest_runtest_makereport作用:对于给定的测试用例(item)和调用步骤(call),返回一个测试报告对象(_pytest.runne......
  • 可视化大屏的终极解决方案居然这么简单,vue-autofit一行全搞定!
    可视化大屏适配/自适应现状可视化大屏的适配是一个老生常谈的话题了,现在其实不乏一些大佬开源的自适应插件、工具但是我为什么还要重复造轮子呢?因为目前市面上适配工具每一个都无法做到完美的效果,做出来的东西都差不多,最终实现效果都逃不出白边的手掌心,可以解决白边问题的,要么太......
  • Auto-GPT 5分钟详细部署指南
    安装conda1.下载安装miniconda3:Miniconda—condadocumentationconda是一个包和环境管理工具,它不仅能管理包,还能隔离和管理不同python版本的环境。类似管理nodejs环境的nvm工具。2.conda环境变量:新建CONDA_HOME:conda安装路径在Path中添加:%CONDA_HOME% 在Path中添加:%CO......
  • iOS:AutoReleasePool
    具体参考文章AutoRelease是依靠AutoreleasePoolPage来进行push和pop进行工作的AutoreleasePoolPage为双向链表,parent字段指向上一层,child指向下一层每个AutoreleasePoolPage的大小为4096字节每个AutoreleasePoolPage最多可以存放505个对象。首个page可以......
  • uiautomator2+python-模拟安卓键盘输入
    这种方法通常用于不知道控件的情况下的输入。第一步需要切换输入法,然后发送adb广播命令,具体使用方法如下d.set_fastinput_ime(True)先清除掉文本框的内容d.press("back")为收起键盘,可能存在键盘阻挡住别的页面元素,需要收起键盘d=u2.connect()d.set_fastinput_ime(Tr......
  • AutoGPT、AgentGPT、BabyAGI、HuggingGPT、CAMEL:各种基于GPT-4自治系统总结
    ChatGPT和LLM技术的出现使得这些最先进的语言模型席卷了世界,不仅是AI的开发人员,爱好者和一些组织也在研究探索集成和构建这些模型的创新方法。各种平台如雨后春笋般涌现,集成并促进新应用程序的开发。AutoGPT的火爆让我们看到越来越多的自主任务和代理利用了GPT-4的API。这些发展......
  • AutoGPT安装及使用
    AutoGPT简介AutoGPT是一个实验性开源应用程序,展示了GPT-4语言模型的功能。该程序由GPT-4驱动,将LLM“思想”链接在一起,以自主实现您设定的任何目标。作为GPT-4完全自主运行的首批例子之一,AutoGPT突破了人工智能的极限。注:AutoGPT也可以使用GPT-3.5运行。Auto-GPT英文官方网站......
  • Alt+Space 快速打开切换程序 - Everything - AutoHotKey
    Alt+Space快速打开切换程序-Everything-AutoHotKey需求电脑切换任务需要用鼠标找,效率比较低,用快捷键Alt+Space打开列表,输入指定关键字回车,切换或打开程序快捷键Alt+Space打开Everything目录"E:\desktopz\everythingJump"用AutoHotKey设置下代码如下!Space::Run......
  • python pyautogui检测鼠标点击事件
    目录pythonpyautogui检测鼠标点击事件pythonpyautogui检测鼠标点击事件在Python中,可以使用pyautogui模块来检测鼠标的点击事件,并判断左键或右键。下面是一个示例代码,可以检测鼠标的点击事件,并根据左键或右键输出不同的信息:pythonCopyimportpyautoguiwhileTrue:tr......