简体   繁体   English

如何使模态背景转到页面底部而不是视口底部?

[英]How can I make my modal background go to the bottom of the page rather than the bottom of the viewport?

I need to make a lightbox for pictures on this portfolio website. 我需要在此投资组合网站上为图片制作一个灯箱。 I have everything hooked up so the image goes to the original size when being clicked on, like a simple lightbox. 我已经将所有东西都连接起来了,因此在单击图像时,图像就变成了原始大小,就像一个简单的灯箱。 But the problem I'm having is that the background behind the modal only goes down to the bottom of the viewport instead of going all the way to the bottom of the page. 但是我遇到的问题是,模态背后的背景只会下降到视口的底部,而不会一直延伸到页面的底部。 Let me know if theres any additional information I can provide. 让我知道我是否可以提供其他信息。

Lightbox Problem 灯箱问题

#overlay {
background: rgba(0,0,0,0.8);
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
display: none;
text-align: center;
}

#overlay img {
    border-radius: 4px solid white;
    margin-top: 10%;
}

#overlay p {
    color: white;
}

Change position to fixed like this: 将位置更改为固定,如下所示:

#overlay {
   background: rgba(0,0,0,0.8);
   width: 100%;
   height: 100%;
   position: fixed;
   top: 0;
   left: 0;
   display: none;
   text-align: center;
}

如何自动使底部居中<div>在视口上?</div><div id="text_translate"><p> 我正在创建一种仅基于纯文本、没有图像或其他任何内容的网站/实验,它仅包含一个&lt;div&gt;包含几个&lt;span&gt;和&lt;a&gt;元素,这些元素在使用 JS 点击时打开,显示堆叠的文本在&lt;div&gt;的底部。</p><p> 当屏幕上覆盖的文本过多时,问题就出现了,并且用户不断点击——因此,显示更多文本——这些新行一直堆叠在底部,不会自动可见:用户必须开始滚动到继续阅读。</p><p> 有没有办法可以自动将&lt;div&gt;的底部放在屏幕<em>的</em>中心,所以它不需要滚动? 当文本填满整个屏幕时,您是否有更好的解决方法来避免手动滚动?</p><p> 谢谢!</p><p> 编辑:我添加了一段代码,以便更好地理解我所做的。 </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-html lang-html prettyprint-override"> &lt;div id="container"&gt; &lt;p class="fade-in"&gt; &lt;a data-opens="1" href="#"&gt;Hello&lt;/a&gt;.&lt;span data-openedby="1" class="fade-in"&gt; How are &lt;a data-opens="2" href="#"&gt;you&lt;/a&gt;? &lt;/span&gt;&lt;span class="fade-in" data-openedby="2"&gt;&lt;a data-opens="3" href="#"&gt;Welcome&lt;/a&gt; to my website.&lt;/span&gt; &lt;/p&gt; &lt;/div&gt;</pre></div></div><p></p><p> 基本上,这段代码,但不是只有三个&lt;a&gt; ,到目前为止,它有 300 个带有各自的&lt;span&gt; 。</p></div> - How can I automatically center the bottom of a <div> on the viewport?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在首页加载时在视口底部放置一个链接? - How can I place a link at the bottom of the viewport on first page load? 如何使 div 从底部平滑扩展到视口的 85%? - How can I make a smooth expanding div from the bottom up to 85% of the viewport? 如何让页面在页脚底部停止滚动? - How can I make a page stop scrolling at the bottom of the footer? 如何自动使底部居中<div>在视口上?</div><div id="text_translate"><p> 我正在创建一种仅基于纯文本、没有图像或其他任何内容的网站/实验,它仅包含一个&lt;div&gt;包含几个&lt;span&gt;和&lt;a&gt;元素,这些元素在使用 JS 点击时打开,显示堆叠的文本在&lt;div&gt;的底部。</p><p> 当屏幕上覆盖的文本过多时,问题就出现了,并且用户不断点击——因此,显示更多文本——这些新行一直堆叠在底部,不会自动可见:用户必须开始滚动到继续阅读。</p><p> 有没有办法可以自动将&lt;div&gt;的底部放在屏幕<em>的</em>中心,所以它不需要滚动? 当文本填满整个屏幕时,您是否有更好的解决方法来避免手动滚动?</p><p> 谢谢!</p><p> 编辑:我添加了一段代码,以便更好地理解我所做的。 </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-html lang-html prettyprint-override"> &lt;div id="container"&gt; &lt;p class="fade-in"&gt; &lt;a data-opens="1" href="#"&gt;Hello&lt;/a&gt;.&lt;span data-openedby="1" class="fade-in"&gt; How are &lt;a data-opens="2" href="#"&gt;you&lt;/a&gt;? &lt;/span&gt;&lt;span class="fade-in" data-openedby="2"&gt;&lt;a data-opens="3" href="#"&gt;Welcome&lt;/a&gt; to my website.&lt;/span&gt; &lt;/p&gt; &lt;/div&gt;</pre></div></div><p></p><p> 基本上,这段代码,但不是只有三个&lt;a&gt; ,到目前为止,它有 300 个带有各自的&lt;span&gt; 。</p></div> - How can I automatically center the bottom of a <div> on the viewport? 使用http访问我的Facebook iframe页面时,如何获得模态而不是弹出窗口? - How can I get a Modal rather than a pop up when using http to access my facebook iframe page? 如何在标题的底部使箭头向上? - how can I make an arrow point upwards at the bottom of my header? 如何放置底部菜单,使其在不同屏幕尺寸下都位于页面底部上方? - How can I position my bottom menu so that it stays above the bottom of the page across different screen sizes? 为什么我的模态在页面底部打开? - Why is my modal opening on the bottom of page? 即使我的链接位于页面底部,如何使我的工具提示显示在我的链接下方? - How do I make my tooltip appear below my link even if my link is at the bottom of the page? 在 function 中返回来自 promise 的响应后,如何将 go 降到底线? - How can I make it go down to the bottom lines after the response from the promise is returned in the function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM