Is it possible to style anonymous flex items explicitly?

前端 未结 4 2110
时光说笑
时光说笑 2020-12-11 23:07

I\'m in the early stages of grasping the basic flexbox concepts. The Using CSS Flexible Boxes article at MDN states (emphasis mine):

Each child of a f

4条回答
  •  天涯浪人
    2020-12-11 23:30

    No. Anonymous boxes cannot be directly targeted for CSS styling. CSS styles need a "hook" in the HTML to attach to. That hook is an HTML tag. Without the tag, CSS has nothing to target. This concept applies across box models, including flex and block formatting contexts.


    More about anonymous boxes:

    From the CSS spec:

    9.2.2.1 Anonymous inline boxes

    Any text that is directly contained inside a block container element must be treated as an anonymous inline element.

    The flexbox specification provides for similar behavior.

    4. Flex Items

    Each in-flow child of a flex container becomes a flex item, and each contiguous run of text that is directly contained inside a flex container is wrapped in an anonymous flex item.

提交回复
热议问题