2017-08-06 48 views

回答

2

既然你已经有2个集装箱,您可以使用2对伪元素的角落,像这样:

.outer { 
 
    width: 120px; 
 
    background: #a08; 
 
    position: relative; 
 
    padding: 30px; 
 
} 
 

 
.inner { 
 
    height: 118px; 
 
    background: #fff; 
 
    border: 1px dashed #a08; 
 
    flex: 1; 
 
} 
 

 
.outer::before, .outer::after, .inner::before, .inner::after { 
 
    content: ''; 
 
    width: 20px; 
 
    height: 20px; 
 
    background: #a08; 
 
    background-clip: padding-box; 
 
    border: 1px dashed #a08; 
 
    border-radius: 50%; 
 
    position: absolute; 
 
    z-index: 1; 
 
} 
 
.outer::before { 
 
    top: 20px; 
 
    left: 20px; 
 
} 
 
.outer::after { 
 
    top: 20px; 
 
    right: 20px; 
 
} 
 
.inner::before { 
 
    bottom: 20px; 
 
    left: 20px; 
 
} 
 
.inner::after { 
 
    bottom: 20px; 
 
    right: 20px; 
 
}
<div class="outer"> 
 
    <div class="inner"></div> 
 
</div>

+0

或者用轮廓作为边框的替代:'outline-color:1px dashed #fff;' –

1

也有同样的问题问here了一些答案,应该帮助的。

+0

这解决了圆角而不是边境去他们。 –