我有以下代码:
<div class="item_1">
<div class="Logo"></div>
<div class="Name"></div>
<div class="Link"></div>
<div class="Inhalt_lightbox">Content 1</div>
</div>
<div class="item_2">
<div class="Logo"></div>
<div class="Name"></div>
<div class="Link"></div>
<div class="Inhalt_lightbox">Content 2</div>
</div>
<div class="item_3">
<div class="Logo"></div>
<div class="Name"></div>
<div class="Link"></div>
<div class="Inhalt_lightbox">Content 3</div>
</div>
当我单击“ item_1”中的链接时,“ item_1”中div“ Inhalt_lightbox”的内容应显示在一个灯箱中。
我怎样才能做到这一点?
谢谢
最佳答案
您可以使用纯CSS实现此目的:
.Inhalt_lightbox {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none
}
.Inhalt_lightbox:target {
opacity:1;
pointer-events: auto;
}
.Inhalt_lightbox > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
background: #fff
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: 0px;
text-align: center;
top: 0px;
width: 24px;
text-decoration: none;
font-weight: bold
}
.close:hover { background: #00d9ff }
<div class="item_1">
<div class="Logo"></div>
<div class="Name"></div>
<div class="Link"><a href="#openModal">Open Modal</a></div>
<div class="Inhalt_lightbox" id="openModal"><div><a href="#close" title="Close" class="close">X</a>
<h2>Modal Box</h2>
<p>This is a sample modal box that can be created using the powers of CSS3.</p>
<p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
</div></div>
</div>
关于jquery - 如何调用包含多个项目的颜色框?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27035976/