简体   繁体   English

弹出感谢信息

[英]Pop Up Thank You Message

I am a graphic designer with some knowledge in HTML, CSS and Javascript.我是一名平面设计师,对 HTML、CSS 和 Javascript 有一定的了解。 My coding knowledge is a bit rusty as I have not developed for years.我的编码知识有点生疏,因为我已经多年没有开发了。

I need to make a "Thank you" popup message for a site that I am developing.我需要为我正在开发的网站制作一条“谢谢”弹出消息。 From my previous knowledge I know that JavaScript can do it, but is there any way to do this without JavaScript?根据我之前的知识,我知道 JavaScript 可以做到,但是没有 JavaScript 有没有办法做到这一点? I would like the site to function the same for those without JavaScript enabled.我希望该网站对于那些没有启用 JavaScript 的人来说也能发挥同样的作用。

In this age of increasing use of dynamic websites, if people want to turn off JavaScript then that's their loss and tough nuggets to them if the website doesn't work.在这个动态网站使用越来越多的时代,如果人们想关闭 JavaScript,那么如果网站无法正常工作,那对他们来说就是他们的损失和艰难的掘金。

However, if you're submitting a form, either:但是,如果您要提交表单,请执行以下任一操作:

  • You are submitting it to another page.您正在将其提交到另一个页面。 Just have this page show a thank you message as part of its content.只需让此页面在其内容中显示感谢信息即可。
  • You are using AJAX to submit it, in which case you already require JavaScript so shouldn't be worried about people not having it enabled.您正在使用 AJAX 提交它,在这种情况下,您已经需要 JavaScript,因此不必担心人们没有启用它。

You could use a CSS Modal box.您可以使用 CSS 模态框。 By using stuff like a div with position:fixed , for example, you could add a div on the middle of your screen on top of everything else, thus rendering a custom box.例如,通过使用带有position:fixeddiv类的东西,您可以在屏幕中间的其他所有内容之上添加一个div ,从而呈现一个自定义框。 The problem is that you might need to do the controlling of the div style through javascript.问题是您可能需要通过 javascript 来控制 div 样式。 You could also do so redirecting to another page with the CSS box.您也可以使用 CSS 框重定向到另一个页面。

I think it's fine doing so in javascript.我认为在 javascript 中这样做很好。 Maybe flash would be a bit more problematic.也许闪存会有点问题。 HTML5 even worst, right now. HTML5 更糟糕,现在。

As mentioned above, you can use CSS to create a Modal.如上所述,您可以使用 CSS 创建一个 Modal。 Using an overlay class and turning its visibility to show or hide on screen will work and changing its background-color property to a solid color desired and lower the opacity.使用覆盖类并将其可见性转换为在屏幕上显示或隐藏将起作用并将其背景颜色属性更改为所需的纯色并降低不透明度。

.overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: #0000007a;
    transition: opacity 200ms;
    visibility: hidden;
    opacity: 0;
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM