html - 如何为 div 元素创建一个盒子阴影包装器?
问题描述
我正在尝试在盒子元素周围放置一个盒子阴影包装器。
我复制了 box 元素的代码,hid all the visible styles
并添加了一个box-shadow
. 但这将各种页面元素分散在各处。
HTML:
<div class = "middleAreaWrap">
<div class = "mainButtons"">
<div id = 'FirstRowButtons'">
<button class = "ButtonOne"">ButtonOne</button>
<button class = "buttonTwo""> ButtonTwo </button>
</div>
<div id = 'SecondRowButtons'">
<button class = "ButtonThree"">ButtonThree</button>
<button class = "buttonFour""> ButtonFour </button>
</div>
</div>
</div>
CSS:
/*BUTTON AREA DIV */
.mainButtons {
z-index: 3;
display: block;
position: relative;
border: 10px solid;
border-style: groove;
border-color: #B9B5B4;
margin-left: auto;
margin-right: auto;
width: 74%;
background-color: aliceblue;
padding: 10px;
bottom: 49px;
height: 30%;
}
/*BUTTON AREA DIV WRAP */
.middleAreaWrap {
z-index: 1;
display: block;
position: relative;
border: 10px hidden;
margin-left: auto;
margin-right: auto;
width: 74%;
background-color: transparent;
padding: 10px;
box-shadow: 0px 0px 30px 15px #B9B5B4;*/
bottom: 49px;
height: 30%;
}
解决方案
不确定这是否是您的意思,但内框是绝对定位的,因此从中移除bottom: 49px
将.mainButtons
防止页面元素分散在各处:
/*BUTTON AREA DIV */
.mainButtons {
z-index: 3;
display: block;
position: relative;
border: 10px solid;
border-style: groove;
border-color: #B9B5B4;
margin-left: auto;
margin-right: auto;
width: 74%;
background-color: aliceblue;
padding: 10px;
height: 30%;
}
/*BUTTON AREA DIV WRAP */
.middleAreaWrap {
z-index: 1;
display: block;
position: relative;
border: 10px hidden;
margin-left: auto;
margin-right: auto;
width: 74%;
background-color: transparent;
padding: 10px;
box-shadow: 0px 0px 30px 15px #B9B5B4;*/
bottom: 49px;
height: 30%;
}
<div class = "middleAreaWrap">
<div class = "mainButtons"">
<div id = 'FirstRowButtons'">
<button class = "ButtonOne"">ButtonOne</button>
<button class = "buttonTwo""> ButtonTwo </button>
</div>
<div id = 'SecondRowButtons'">
<button class = "ButtonThree"">ButtonThree</button>
<button class = "buttonFour""> ButtonFour </button>
</div>
</div>
</div>
推荐阅读
- jquery - jQuery帖子中的gzip
- bash - 为什么Input中的文件不会移动到带有前缀的目录Output?
- r - INTEGER() 只能应用于“整数”,而不是 R 中的“双精度”?
- javascript - 单击元素后,HtmlUnit 无法更改页面
- python - 在 Python 中处理可选值的最佳方法是什么?
- java - System.out.println 只打印一个空行
- grafana - 如何显示每个时间间隔发出的命令的 Grafana 仪表板
- javascript - 为什么我收到 ArgumentError(错误数量的参数(给定 0,预期为 1)进行销毁操作?Rails 5.2
- c# - MahApps DateTimePicker 自定义日期时间格式
- android - 为什么在不指定 IntentFilter 的情况下隐式电子邮件 Intent 可以工作?