html - 给边框添加阴影

标签 html css

如您所见,我创建了一个侧边栏:

<div id="sideBar">
<button class="button">Home</button><br>
<button class="button">About Me</button><br>
<button class="button">Gallery</button><br>
<button class="button">Contact</button>
</div>
<div id="content">
    <p>Content Div</p>
</div>  

我的CSS:

#sideBar {
background-color: grey;
width: 200px;
float: left;
height: 200px;
-webkit-box-shadow: inset -16px 0px 10px -8px rgba(0,0,0,0.75);
-moz-box-shadow: inset -16px 0px 10px -8px rgba(0,0,0,0.75);
box-shadow: inset -16px 0px 10px -8px rgba(0,0,0,0.75);
}

.button {
background-color: grey;
border-width: 0 0 2px 0;
border-color: white;
border-style: solid;
color: rgb(231, 231, 231);
cursor: pointer;
-webkit-box-shadow: inset -16px 0px 10px -8px rgba(0,0,0,0.75);
-moz-box-shadow: inset -16px 0px 10px -8px rgba(0,0,0,0.75);
box-shadow: inset -16px 0px 10px -8px rgba(0,0,0,0.75);
width: 200px;
}

#content {
background-color: white;
color: black;
float: left;
width: 200px;
border: 1px solid black;
height: 200px;
}

#content p {
margin-left: 20px;
}

fiddle : http://jsfiddle.net/of4dcp2u/1/

我使用了一些内部阴影。唯一的问题是我无法在边界线上获得阴影效果。白色边框没有任何阴影。

我不想为按钮使用任何图像。这个问题有解决方案吗?

最佳答案

Sam,像这样给内容 div 添加阴影

.button {
    background-color: grey;
    border-width: 0 0 2px 0;
    border-color: white;
    border-style: solid;
    color: rgb(231, 231, 231);
    cursor: pointer;

    width: 200px;
}

#content {
    background-color: white;
    color: black;
    float: left;
    width: 200px;
    border: 1px solid black;
    height: 200px;
     -webkit-box-shadow: -16px 0px 10px -8px rgba(0,0,0,0.75);
    -moz-box-shadow: -16px 0px 10px -8px rgba(0,0,0,0.75);
    box-shadow: -16px 0px 10px -8px rgba(0,0,0,0.75);
}

关于html - 给边框添加阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28585687/

相关文章:

html - 是否可以在警报中使用 Bootstrap (v3) 网格系统?

javascript - 如何在纯 JavaScript 和 AJAX 上访问本地 json 文件并加载包含内容的菜单?

php - 变量和字符串显然不匹配

css - 在 Bootstrap 中创建基本的圆形

html - 具有固定宽度子元素的响应式布局

javascript - 在交互式应用程序中拖放游戏

javascript - 单选按钮值的返回类型是整数还是字符串

html - 如何在 MVC 中将 href 合并到带有 Html.ActionLink 的部分?

HTML 正文高度 - 固定?

html - 使 bootstrap 2 无响应