gpt4 book ai didi

html - 覆盖单个 Div

转载 作者:行者123 更新时间:2023-11-27 23:51:45 25 4
gpt4 key购买 nike

如果他们不是订阅者,我试图在我的页面上的 div 顶部放置一个叠加层,并在其中心使用按钮订阅该网站。我在让叠加层进入正确的 div 而不是在其中时遇到问题..但要将其全部变灰...

在帖子末尾有来自控制台的 span5 和 well 的实际 CSS

我有一个包含以下 HTML 的页面:

  <div class="row-fluid">
<div class="span2 well>
...
</div>
<div class="span5 well">
<h3>EZ Search</h3>
<a class="btn btn-primary" href="/searches/new">Advanced Search</a>
<hr/>
<%= render partial: "searches/ezsearch", locals: {search: @search, user_id: current_user.id} %>
</div>
<div class="span5 well>
...
</div>
</div>

这是我现在拥有的页面图像:

enter image description here

并希望它看起来像这样:

enter image description here

这是我的 CSS 中的内容:

.overlay{
z-index: 20;
width: 100%;
height: 100%;
position: absolute;
}

.overlay .blackbg {
z-index: 25;
color: #000;
background-color: #000;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
opacity: 0.5;
}

.overlay .button {
z-index: 30;
color: white;
}

这里是span5和well的css

.row-fluid .span5 {
width: 40.1709%;
}
.row-fluid [class*="span"] {
-moz-box-sizing: border-box;
display: block;
float: left;
margin-left: 2.5641%;
min-height: 30px;
width: 100%;
}
.row-fluid .span5 {
width: 40.4255%;
}
.row-fluid [class*="span"] {
-moz-box-sizing: border-box;
display: block;
float: left;
margin-left: 2.12766%;
min-height: 30px;
width: 100%;
}
.well {
background: none repeat scroll 0 0 #E6E6E6;
box-shadow: 3px 3px 5px 6px #CCCCCC;
}
.span5 {
width: 470px;
}
[class*="span"] {
float: left;
margin-left: 30px;
min-height: 1px;
}
.well {
background-color: #F5F5F5;
border: 1px solid #E3E3E3;
border-radius: 4px 4px 4px 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05) inset;
margin-bottom: 20px;
min-height: 20px;
padding: 19px;
}
.span5 {
width: 380px;
}
[class*="span"] {
float: left;
margin-left: 20px;
min-height: 1px;
}

最佳答案

您可以像这样简化叠加样式:

.overlay{
z-index: 20;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,.5); /* this will give you the 50% black background without the extra element */
color: #000;
}

.overlay .button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%); /* object is aligned centered based on the top left corner, this adjusts it to true center */
z-index: 30;
color: white;
}

这里是稍微调整过的 HTML:

<div class="span5 well">
<div class="overlay">
<a class="btn btn-primary button" href="/searches/new">Sign Up Now!</a>
</div>
<h3>EZ Search</h3>
<a class="btn btn-primary" href="/searches/new">Advanced Search</a>
<hr/>
<p>...</p>
</div>

JSFiddle Demo

关于html - 覆盖单个 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26786196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com