可以将HTML内容放在画布上(登录页)
Possible to put HTML Content on top of a Canvas (Landing Page)
我有一个画布设置,其中有许多粒子在屏幕上移动。当用户单击时,会添加更多粒子。问题是,这个粒子系统是用于登录页的。
我有画布在工作,但是如果我想向登录页添加文本,我不能。这可能吗?我希望屏幕中央有"欢迎",但是如果我把它添加到粒子所在的HTML代码中,它是不可见的。
---我的HTML---
<div id="particles-js"></div>
<div class="count-particles">
<span class="js-count-particles">--</span> particles
</div>
---CSS——
/* ---- reset ---- */
body {
margin: 0;
font:normal 75% Arial, Helvetica, sans-serif;
}
canvas {
display: block;
vertical-align: bottom;
}
/* ---- particles.js container ---- */
#particles-js {
position: absolute;
width: 100%;
height: 100%;
background-color: blue;
background-image: url("");
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
}
/* ---- stats.js ---- */
.count-particles{
background: #000022;
position: absolute;
top: 48px;
left: 0;
width: 80px;
color: #13E8E9;
font-size: .8em;
text-align: left;
text-indent: 4px;
line-height: 14px;
padding-bottom: 2px;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
}
.js-count-particles{
font-size: 1.1em;
}
#stats,
.count-particles{
-webkit-user-select: none;
margin-top: 5px;
margin-left: 5px;
}
#stats{
border-radius: 3px 3px 0 0;
overflow: hidden;
}
.count-particles{
border-radius: 0 0 3px 3px;
}
我有一个Codepen.io设置,非常感谢任何帮助!
-Codepen.io-http://codepen.io/HoneyBadgerYT/pen/jqKZxo
您可以使用css 来完成此操作
h1 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
html:
<div id="particles-js"></div>
<h1>Welcome</h1>
<div class="count-particles">
<span class="js-count-particles">--</span> particles
</div>
请参阅的工作演示
如果添加另一个元素(如h2或div),则需要给它一个position:absolute
和一个高于#particle-js
的z-index
的z-index
参见以下html:
(请注意,我为#particle-js
元素添加了一个z-index
属性,并在其下方添加了h2
样式。)
<div id="particles-js"></div>
<h2>WELCOME</h2>
<div class="count-particles">
<span class="js-count-particles">--</span> particles
</div>
和CSS
/* ---- reset ---- */
body {
margin: 0;
font:normal 75% Arial, Helvetica, sans-serif;
}
canvas {
display: block;
vertical-align: bottom;
}
/* ---- particles.js container ---- */
#particles-js {
position: absolute;
width: 100%;
height: 100%;
background-color: blue;
background-image: url("");
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
z-index:1;
}
h2 {
position:absolute;
z-index:2;
width:100%;
text-align:center;
color:#ffffff;
top:0;
left:0;
}
/* ---- stats.js ---- */
.count-particles{
background: #000022;
position: absolute;
top: 48px;
left: 0;
width: 80px;
color: #13E8E9;
font-size: .8em;
text-align: left;
text-indent: 4px;
line-height: 14px;
padding-bottom: 2px;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
}
.js-count-particles{
font-size: 1.1em;
}
#stats,
.count-particles{
-webkit-user-select: none;
margin-top: 5px;
margin-left: 5px;
}
#stats{
border-radius: 3px 3px 0 0;
overflow: hidden;
}
.count-particles{
border-radius: 0 0 3px 3px;
}
相关文章:
- Javascript,在body_class()=登录时更改内部html
- 隐藏我的管理员登录信息 HTML
- 单击按钮时切换html登录/注册表单
- 可以将HTML内容放在画布上(登录页)
- HTML文件到自动登录表单
- 用用户上次登录时选择的内容填充html表单
- 使用自制的html表单注册/登录网站
- 登录到网站并从页面获取html
- 无法获取使用 HTML 简单登录到 PHP Web 服务的数据
- 如何在 PHP 的 HTML 页面中动态更改登录和注销链接
- 仅使用 HTML/CSS/JavaScript 的下拉登录菜单
- 在 HTML 登录页面中重新创建命令解释器的最佳方法
- HTML 登录不起作用
- 根据用户登录凭据(Lightswitch HTML)添加数据
- 如果不登录,则重定向 HTML 页面
- 如何在 html/css 中制作下拉登录菜单
- 我可以阻止我的 HTML 页面加载,直到我的 Facebook 登录状态脚本运行之后
- 登录表单Mysqli php与HTML
- 允许访客和网站成员查看谁在线/登录使用AJAX,PHP / PDO,CSS,HTML
- 滑动登录面板与HTML,CSS,Jquery