我的css内部阴影有问题。
我已从codepen.io
创建了 DEMO所以问题是图像上的内部阴影无法显示。你会看到你点击图像底部的演示链接无法显示内部阴影。
如何在图像上查看内部阴影?
HTML:
body {
background-color: #323949;
font-family: 'mstfont' !important;
margin: 0px;
padding: 0px;
min-width: 100%;
float: left;
height: 100%;
-webkit-backface-visibility: hidden;
}
.globalHeader {
z-index: 90;
background-color: #323949;
position: fixed;
width: 100%;
border-bottom: 1px solid #3f4858;
color: #fff;
font-size: 40px;
font-family: arial, sans-serif;
-webkit-box-shadow: 0px 0px 5px #000000;
-moz-box-shadow: 0px 0px 5px #000000;
box-shadow: 0px 0px 5px #000000;
}
.globalHeader_in {
z-index: 99999;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
position: relative;
min-width: 960px;
width: 100%!important;
max-width: 1580px;
height: 52px;
left: 0;
top: 0;
padding: 0 20px 0 15px;
margin: auto;
}
.profil-kapak {
width: 100%;
height: 385px;
border-bottom: 1px solid #3f4858;
-moz-box-shadow: inset 0 0 5px #000000;
-webkit-box-shadow: inset 0 0 5px #000000;
box-shadow: inset 0 0 5px #000000;
}
.image {
margin: 0px auto;
width: 900px;
height: 385px;
overflow: hidden;
}
.image img {
width: 100%;
}
<div class="globalHeader">
<div class="globalHeader_in">header</div>
</div>
<div class="profil-kapak">
<div class="image">
<img src="http://www.designbolts.com/wp-content/uploads/2013/11/Frozen-Movie-poster-payoff-Wallpaper-HD1.jpg">
</div>
</div>
答案 0 :(得分:3)
您无法为图像添加内部阴影。相反,你可以做的是将父.image
设置为positon:relative
,并创建一个覆盖设置为position:absolute
的框阴影:
<强> HTML 强>
<div class="image">
<div class="overlay"></div>
<img src="..."></div>
</div>
<强> CSS 强>
.overlay{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
-moz-box-shadow: inset 0 0 10px #000000;
-webkit-box-shadow: inset 0 0 10px #000000;
box-shadow: inset 0 0 10px #000000;
}
(切换到小提琴,我只是习惯了):
答案 1 :(得分:1)
.img-shadow {
position: relative;
display: inline-block;
}
.img-shadow::after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
box-shadow: 0 0 10px 14px rgba(90,0,90,0.65) inset;
content: "";
}
.img-shadow>img {
vertical-align: top;
}
<span class="img-shadow">
<img width=280px; src="http://www.accordionplus.ru/wp-content/uploads/2014/10/1_web_mini.jpg">
</span>