它是图像模式,顶部有半透明div。我想成功,但不能。我做了div,但它不会出现,无论我如何建立CSS ... 直到现在,我有这个代码:
<div id="imgmodal">
<div class="semi-transparent">
<a id="download-link" download="Slika Testa"><span class="glyphicon glyphicon-download"></span></a>
<span id="close">×</span>
</div>
<img class="content" id="img">
</div>
和css:
/* exam_img */
#imgmodal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%; /* Full height */
background-color: rgb(0,0,0); /* Fallback color */
overflow: auto;
background-color: rgb(0,0,0); /* Black w/ opacity */
transition: 0.3s;
}
/* Modal Content (image) */
.content {
margin: auto;
display: block;
width: auto;
max-width: 100%;
height: auto;
max-height: 95%;
position: relative;
top: calc(50% - 25px);
top: -moz-calc(50% - 25px);
top: -webkit-calc(50% - 25px);
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
}
/* Add Animation */
.content{
-webkit-animation-name: zoom;
-webkit-animation-duration: 1s;
animation-name: zoom;
animation-duration: 1s;
}
@-webkit-keyframes zoom {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes zoom {
0% { opacity: 0; }
100% { opacity: 1; }
}
/* The Close Button */
#close {
position: absolute;
top: 15px;
right: 35px;
color: #f1f1f1;
font-size: 40px;
font-weight: 100;
transition: 0.3s;
}
#close:hover,
#close:focus {
color: #989898;
text-decoration: none;
cursor: pointer;
}
#download-link{
position: absolute;
font-size: 25px;
color: #f1f1f1;
font-weight: normal;
text-decoration: none;
transition: 0.2s;
top: 27px;
left: 35px;
}
#download-link:hover {
color: #989898;
}
/* 100% Image Width on Smaller Screens */
@media only screen and (max-width: 768px){
.content {
}
#close {
top: 2px;
font-size: 40px;
}
#imgmodal {
padding-top: 50px;
}
#download-link {
top: 15px;
}
}
.semi-transparent {
?
}
答案 0 :(得分:1)
要将.semi-transparent
放在这样的图像上,您可以使用position: absolute
将菜单放在图像的顶部,然后opacity
使整个条形图显示为半透明。< / p>
/* exam_img */
#imgmodal {
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%; /* Full height */
background-color: rgb(0,0,0); /* Fallback color */
overflow: auto;
background-color: rgb(0,0,0); /* Black w/ opacity */
transition: 0.3s;
}
/* Modal Content (image) */
.content {
margin: auto;
display: block;
width: auto;
max-width: 100%;
height: auto;
max-height: 95%;
position: relative;
top: calc(50% - 25px);
top: -moz-calc(50% - 25px);
top: -webkit-calc(50% - 25px);
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
}
/* Add Animation */
.content{
-webkit-animation-name: zoom;
-webkit-animation-duration: 1s;
animation-name: zoom;
animation-duration: 1s;
}
@-webkit-keyframes zoom {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes zoom {
0% { opacity: 0; }
100% { opacity: 1; }
}
/* The Close Button */
#close {
position: absolute;
top: 15px;
right: 35px;
color: #f1f1f1;
font-size: 40px;
font-weight: 100;
transition: 0.3s;
}
#close:hover,
#close:focus {
color: #989898;
text-decoration: none;
cursor: pointer;
}
#download-link{
position: absolute;
font-size: 25px;
color: #f1f1f1;
font-weight: normal;
text-decoration: none;
transition: 0.2s;
top: 27px;
left: 35px;
}
#download-link:hover {
color: #989898;
}
/* 100% Image Width on Smaller Screens */
@media only screen and (max-width: 768px){
.content {
}
#close {
top: 2px;
font-size: 40px;
}
#imgmodal {
padding-top: 50px;
}
#download-link {
top: 15px;
}
}
.semi-transparent {
text-align: center;
color: white;
position: absolute;
top: 0; left: 0; right: 0;
opacity: 0.8;
padding: 2em 0;
}
&#13;
<div id="imgmodal">
<a id="download-link" download="Slika Testa"><span class="glyphicon glyphicon-download"></span></a>
<span id="close">×</span>
<img class="content" id="img" src="http://cdn.thedailybeast.com/content/dailybeast/articles/2015/03/31/neil-degrasse-tyson-defends-scientology-and-the-bush-administration-s-science-record/jcr:content/image.img.2000.jpg/1432067001553.cached.jpg">
<div class="semi-transparent">foobar
</div>
</div>
&#13;