【发布时间】:2013-08-14 05:31:58
【问题描述】:
我正在尝试创建一个带有 3 层边框的按钮,中间层显示包含 div 的背景。例子值一千字,所以你去吧
html
<div id="content">
<p>Generic Content</p>
<button class="button">Search</button>
</div>
css
#content{
width: 500px;
height: 500px;
background-color: black;
padding: 50px;
color: white;
}
button{
margin-top: 50px;
padding: 20px;
text-align: center;
background-color: #333;
box-shadow: 0 0 0 5px #666, 0 0 0 10px red, 0 0 0 15px #bbb;
border: none;
cursor: pointer;
}
红色框阴影是包含 div 的黑色应该穿过的地方。如果该图层的 box-shadow 设置为透明,则其下方的 box-shadow 会显示出来。
到目前为止,我已经尝试过使用轮廓、边框和框阴影无济于事。截至目前,我认为我必须将按钮包装在另一个带有外边框和填充以显示背景的 div 中,但我想看看是否有人可以在不添加另一个 html 元素的情况下做到这一点。
谢谢!
【问题讨论】: