0

“焦点”周围和框周围的边框。简单地说。如何在 CSS 上重新创建它。取自 theatlantic.com。

在此处输入图像描述

4

1 回答 1

0

尝试这样的事情:

CSS:

div.box
{
    width: 200px;
    height: 120px;
    text-align: center;
    line-height: 120px;
    position: relative;
    background: #CCC;
}

div.box > span
{
    display: block;
    position: absolute;
    width: 20px;
    height: 20px;
    top: 0;
    left: 0;
    border-top: 1px solid red;
    border-left: 1px solid red;
}

div.box > span + span
{
    top: 0;
    left: 100%;
    border-left: none;
    border-right: 1px solid red;
    margin-left: -20px;
}

div.box > span + span + span
{
    top: 100%;
    left: 100%;
    border-top: none;
    border-bottom: 1px solid red;
    margin-top: -20px;
}

div.box > span + span + span + span
{
    top: 100%;
    left: 0;
    border-right: none;
    border-left: 1px solid red;
    margin-left: 0;
}

HTML:

<div class="box">
    <span></span>
    <span></span>
    <span></span>
    <span></span>

    Hello.
</div>

JSFiddle 在这里

于 2013-01-15T05:31:43.227 回答