display:contents

简介: display:contents

多少人以友谊的名义,爱着一个人。——电影《One Day》

MDNhttps://developer.mozilla.org/zh-CN/docs/Web/CSS/display-box

首先是一段代码:

<!DOCTYPE html>
<head>
    <title>display</title>
    <style>
        .outer {
            border: 2px solid red;
            width: 300px;
        }
        .outer>div {
            border: 1px solid green;
        }
</style>
</head>
<body>
    <div class="outer">
        <div>Inner div.</div>
    </div>
</body>


渲染效果为:

当我们给外部的outer添加一个display:contents;

<!DOCTYPE html>
<head>
    <title>display</title>
    <style>
        .outer {
            border: 2px solid red;
            width: 300px;
            display: contents;
        }
        .outer>div {
            border: 1px solid green;
        }
</style>
</head>
<body>
    <div class="outer">
        <div>Inner div.</div>
    </div>
</body>

可以看到外部的元素消失,只保留了子元素

相关文章
[√]addr2line
[√]addr2line
183 0
|
编译器 C语言
__FILE__, __LINE__ __FUNCTION__
__FILE__, __LINE__ __FUNCTION__
|
Java
解决Command line is too long. Shorten command line for ServiceStarter or also for Application报错
解决Command line is too long. Shorten command line for ServiceStarter or also for Application报错
400 0
成功解决OSError: cannot open resource self.font = core.getfont(font, size, index, encoding, layout_engin
成功解决OSError: cannot open resource self.font = core.getfont(font, size, index, encoding, layout_engin
|
C#
C#: Get current keyboard layout\input language
原文 https://yal.cc/csharp-get-current-keyboard-layout/   On some occasions, you may want to get a "global" input language - that is, the keyboard layo...
1110 0
|
C#
Beginner’s Tutorial: 3D Line and Border Effects in XAML
This mini-tutorial might be for you if you’re having troubles finding the right line colors to achieve simple 3D effects like these:   The solutio...
1157 0