CSS 可以影响可替换元素的位置,但不会影响到可替换元素自身的内容
典型的可替换元素有:
有些元素仅在特定情况下被作为可替换元素处理,例如:
关于伪类和伪元素
CSS introduces the concepts of pseudo-elements and pseudo-classes to permit formatting based on information that lies outside the document tree.
伪类:CSS 伪类 是添加到选择器的关键字,指定要选择的元素的特殊状态。例如,:hover 可被用于在用户将鼠标悬停在按钮上时改变按钮的颜色。
伪元素:伪元素是一个附加至选择器末的关键词,允许你对被选择元素的特定部分修改样式。一个选择器中只能使用一个伪元素。伪元素必须紧跟在语句中的简单选择器/基础选择器之后。
块格式化上下文(Block Formatting Context,BFC)A block formatting context is a part of a visual CSS rendering of a web page. It‘s the region in which the layout of block boxes occurs and in which floats interact with other elements.
浮动定位和清除浮动时只会应用于同一个BFC内的元素。浮动不会影响其它BFC中元素的布局,而清除浮动只能清除同一BFC中在它前面的元素的浮动。外边距折叠(Margin collapsing)也只会发生在属于同一BFC的块级元素之间。
创建块格式化上下文:
html)float 不是 none)position 为 absolute 或 fixed)display 为 inline-block)display为 table-cell,HTML表格单元格默认为该值)display 为 table-caption,HTML表格标题默认为该值)display为 table、``table-row、 table-row-group、``table-header-group、``table-footer-group(分别是HTML table、row、tbody、thead、tfoot的默认属性)或 inline-table)overflow 值不为 visible 的块元素display 值为 flow-root 的元素contain 值为 layout、content或 paint 的元素display为 flex 或 inline-flex元素的直接子元素)display为 grid 或 inline-grid 元素的直接子元素)column-count 或 column-width 不为 auto,包括 ``column-count 为 1)column-span 为 all 的元素始终会创建一个新的BFC,即使该元素没有包裹在一个多列容器中(标准变更,Chrome bug)。原文:https://www.cnblogs.com/seny-33/p/12548280.html