您的 div 的高度为零。所以它不会出现。linear-gradient
此外,您可以使用CSS3 的属性将div 填充为透明色。
<div class="outerDiv">
<div class="innerDiv">
<div>test</div>
</div>
</div>
CSS 如下所示:您可以从 colorzilla.com/gradient-editor 轻松获取 CSS 代码
.outerDiv {
width:128px;
height:128px;
overflow:hidden;
position:relative;
margin-left:auto;
margin-right:auto;
}
.innerDiv {
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzk0ZDg2MyIgc3RvcC1vcGFjaXR5PSIwLjUiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzk0ZDg2MyIgc3RvcC1vcGFjaXR5PSIwLjUiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZ3JhZC11Y2dnLWdlbmVyYXRlZCkiIC8+Cjwvc3ZnPg==);
background: -moz-linear-gradient(top, rgba(148,216,99,0.5) 0%, rgba(148,216,99,0.5) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(148,216,99,0.5)), color-stop(100%,rgba(148,216,99,0.5))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(148,216,99,0.5) 0%,rgba(148,216,99,0.5) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(148,216,99,0.5) 0%,rgba(148,216,99,0.5) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(148,216,99,0.5) 0%,rgba(148,216,99,0.5) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(148,216,99,0.5) 0%,rgba(148,216,99,0.5) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8094d863', endColorstr='#8094d863',GradientType=0 ); /* IE6-8 */
/* IE6-8 */
width:100%;
bottom:0;
}
小提琴在这里