Use a DIV as a background for another element

前端 未结 2 1785
后悔当初
后悔当初 2020-12-25 13:28

If I have a div that contains images and text, is it possible to use this div\'s content as a background for, let\'s say, a section ?<

2条回答
  •  难免孤独
    2020-12-25 13:47

    Use the CSS element() function. See https://developer.mozilla.org/en-US/docs/Web/CSS/element. Currently available only in FF under the -moz-element prefix. Example:

    An alternative would be to play with SVG's foreignObject tag, cloning the HTML for the element you want to use as background into it.

    Spec is at http://dev.w3.org/csswg/css-images/#element-notation.

提交回复
热议问题