- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在创建一个 JS 动画,我想将此动画放在文本和所有其他元素后面。
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="stylesheet" href="http://hub.chemdoodle.com/cwc/latest/ChemDoodleWeb.css" type="text/css">
<script type="text/javascript" src="http://hub.chemdoodle.com/cwc/latest/ChemDoodleWeb.js"></script>
<title>Molecules</title>
</head>
<body>
<h1 style="font-size:300%; text-align: center; font-family: Menlo;">Molecules</h1>
<script>
var w = window.innerWidth;
var h = window.innerHeight;
console.log('WIDTH', w, 'AND HEIGHT', h);
var rotate3D = new ChemDoodle.RotatorCanvas('rotate3D', w, h, true);
rotate3D.specs.atoms_useJMOLColors = true;
rotate3D.specs.atoms_circles_2D = true;
rotate3D.specs.bonds_symmetrical_2D = true;
var exampleMolFile = 'Molecule Name\n CHEMDOOD12250908183D 0 0.00000 0.00000 0\n[Insert Comment Here]\n 40 44 0 0 0 0 0 0 0 0 1 V2000\n -2.4201 -1.3169 0.4885 C 0 0 0 1 0 0 0 0 0 0 0 0\n -2.4007 -0.2197 0.6870 C 0 0 0 1 0 0 0 0 0 0 0 0\n -3.1630 -1.7585 0.5832 H 0 0 0 1 0 0 0 0 0 0 0 0\n -1.4920 -1.8472 0.1276 C 0 0 0 1 0 0 0 0 0 0 0 0\n -3.3129 0.2911 0.9878 O 0 0 0 1 0 0 0 0 0 0 0 0\n -1.4550 0.3261 0.5477 C 0 0 0 1 0 0 0 0 0 0 0 0\n -0.5339 -1.2844 -0.0016 C 0 0 0 1 0 0 0 0 0 0 0 0\n -1.5355 -2.6937 -0.0688 H 0 0 0 1 0 0 0 0 0 0 0 0\n -3.1138 1.0345 1.1162 H 0 0 0 1 0 0 0 0 0 0 0 0\n -0.5385 -0.2088 0.2615 C 0 0 0 1 0 0 0 0 0 0 0 0\n -1.3162 1.4114 0.6041 O 0 0 0 1 0 0 0 0 0 0 0 0\n 0.4574 -1.7528 -0.5024 C 0 0 0 1 0 0 0 0 0 0 0 0\n 0.3884 0.5420 0.1963 C 0 0 0 1 0 0 0 0 0 0 0 0\n -0.2569 1.5925 0.1057 C 0 0 0 1 0 0 0 0 0 0 0 0\n 0.6675 -2.4994 -0.0963 H 0 0 0 1 0 0 0 0 0 0 0 0\n 1.4380 -0.9689 -0.5556 C 0 0 0 1 0 0 0 0 0 0 0 0\n 0.2503 -1.9697 -1.3283 H 0 0 0 1 0 0 0 0 0 0 0 0\n 1.0495 0.4819 1.2355 C 0 0 0 1 0 0 0 0 0 0 0 0\n 1.0919 0.2175 -0.7577 C 0 0 0 1 0 0 0 0 0 0 0 0\n 0.1184 2.2301 0.5784 H 0 0 0 1 0 0 0 0 0 0 0 0\n -0.3921 2.0169 -1.0582 C 0 0 0 1 0 0 0 0 0 0 0 0\n 1.9358 -1.2202 -1.2354 H 0 0 0 1 0 0 0 0 0 0 0 0\n 2.1438 -0.9618 0.4030 N 0 0 0 1 0 0 0 0 0 0 0 0\n 1.6007 -0.6068 1.3817 C 0 0 0 1 0 0 0 0 0 0 0 0\n 0.5521 0.6440 1.9410 H 0 0 0 1 0 0 0 0 0 0 0 0\n 1.6648 1.1088 1.2152 H 0 0 0 1 0 0 0 0 0 0 0 0\n 0.5456 0.4220 -1.8161 C 0 0 0 1 0 0 0 0 0 0 0 0\n 1.8191 0.7140 -0.7698 H 0 0 0 1 0 0 0 0 0 0 0 0\n -1.4411 2.4257 -1.2400 O 0 0 0 1 0 0 0 0 0 0 0 0\n -0.1380 1.2410 -1.9394 C 0 0 0 1 0 0 0 0 0 0 0 0\n 0.1565 2.6937 -1.1652 H 0 0 0 1 0 0 0 0 0 0 0 0\n 2.6986 -1.9758 0.5733 C 0 0 0 1 0 0 0 0 0 0 0 0\n 2.1879 -0.5234 2.0289 H 0 0 0 1 0 0 0 0 0 0 0 0\n 1.0187 -1.2041 1.6545 H 0 0 0 1 0 0 0 0 0 0 0 0\n 0.7435 -0.0833 -2.4955 H 0 0 0 1 0 0 0 0 0 0 0 0\n -1.9229 1.9705 -0.8287 H 0 0 0 1 0 0 0 0 0 0 0 0\n -0.4917 1.3949 -2.7191 H 0 0 0 1 0 0 0 0 0 0 0 0\n 3.1158 -2.2288 -0.1548 H 0 0 0 1 0 0 0 0 0 0 0 0\n 3.3129 -1.8835 1.1918 H 0 0 0 1 0 0 0 0 0 0 0 0\n 2.1618 -2.6206 0.8240 H 0 0 0 1 0 0 0 0 0 0 0 0\n 1 2 2 0 0 0 0\n 1 3 1 0 0 0 0\n 1 4 1 0 0 0 0\n 2 5 1 0 0 0 0\n 2 6 1 0 0 0 0\n 7 4 2 0 0 0 0\n 4 8 1 0 0 0 0\n 5 9 1 0 0 0 0\n 6 10 2 0 0 0 0\n 6 11 1 0 0 0 0\n 10 7 1 0 0 0 0\n 7 12 1 0 0 0 0\n 10 13 1 0 0 0 0\n 14 11 1 0 0 0 0\n 12 15 1 0 0 0 0\n 16 12 1 0 0 0 0\n 12 17 1 0 0 0 0\n 13 18 1 0 0 0 0\n 13 14 1 0 0 0 0\n 13 19 1 0 0 0 0\n 14 20 1 0 0 0 0\n 21 14 1 0 0 0 0\n 16 22 1 0 0 0 0\n 19 16 1 0 0 0 0\n 16 23 1 0 0 0 0\n 18 24 1 0 0 0 0\n 18 25 1 0 0 0 0\n 18 26 1 0 0 0 0\n 19 27 1 0 0 0 0\n 19 28 1 0 0 0 0\n 21 29 1 0 0 0 0\n 30 21 1 0 0 0 0\n 21 31 1 0 0 0 0\n 23 32 1 0 0 0 0\n 23 24 1 0 0 0 0\n 24 33 1 0 0 0 0\n 24 34 1 0 0 0 0\n 27 35 1 0 0 0 0\n 27 30 2 0 0 0 0\n 29 36 1 0 0 0 0\n 30 37 1 0 0 0 0\n 32 38 1 0 0 0 0\n 32 39 1 0 0 0 0\n 32 40 1 0 0 0 0\nM END';
var mol = ChemDoodle.readMOL(exampleMolFile);
rotate3D.loadMolecule(mol);
rotate3D.startAnimation();
</script>
<p>
Hydrogen bonding plays a significant role in many chemical and biological pro- cesses, including ligand binding and enzyme catalysis. Consideration of hydro- gen-bonding properties in drug design is important because of their strong influ- ence on specificity of binding, transport, adsorption, distribution, metabolization, and excretion properties of small molecules. Their ubiquity and flexibility make hydrogen bonds the most important physical interaction in systems of biomole- cules in aqueous solution. Because hydrogen atoms comprise approximately one- half of the atoms within biological macromolecules and two-thirds of the atoms of the solvating water, hydrogen atoms, or protons, are found between almost every pair of non-covalently bonded heavy atoms in a biological system. Since the basic necessary condition for a hydrogen bond being present is that a proton lies be- tween the electron clouds of two other atoms and modifies their interaction in a manner that is not explicable in terms of the van der Waals (dispersion-repulsion) effect, hydrogen bonds almost rival van der Waals interactions in number.
</p>
</body>
</html>
还有
我不拥有此文本。我只是为了实验而放它。
我保留框架是为了跟踪。我找不到如何将 x, y 设置为 0,0 或类似的方式,以使脚本不在标题 <h1>
下出现,而是在其后面且处于同一级别。
如何将此脚本置于后台?
最佳答案
您可以使用 CSS 将它们相互放置:
通过将元素包装在 div 中,您可以控制分层的位置和 z-index。
标记:
<div id="wrapper">
<div id="content">
// YOUR CONTENT
</div>
<div id="animation">
// YOUR CANVAS SCRIPT
</div>
</div>
CSS:
#wrapper {
position: relative;
}
#content {
position: relative;
z-index: 1;
}
#animation {
position: absolute;
top: 0;
z-index: 0;
}
https://jsfiddle.net/mattBBP/m0Lo5v6w/
您可能需要确保内容具有 Canvas 动画的最小高度,以防止其被切断:
#content {
...
min-height: 400px;
}
关于javascript - 将 javascript 动画置于背景的最简单方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37945192/
我想了解 Ruby 方法 methods() 是如何工作的。 我尝试使用“ruby 方法”在 Google 上搜索,但这不是我需要的。 我也看过 ruby-doc.org,但我没有找到这种方法。
Test 方法 对指定的字符串执行一个正则表达式搜索,并返回一个 Boolean 值指示是否找到匹配的模式。 object.Test(string) 参数 object 必选项。总是一个
Replace 方法 替换在正则表达式查找中找到的文本。 object.Replace(string1, string2) 参数 object 必选项。总是一个 RegExp 对象的名称。
Raise 方法 生成运行时错误 object.Raise(number, source, description, helpfile, helpcontext) 参数 object 应为
Execute 方法 对指定的字符串执行正则表达式搜索。 object.Execute(string) 参数 object 必选项。总是一个 RegExp 对象的名称。 string
Clear 方法 清除 Err 对象的所有属性设置。 object.Clear object 应为 Err 对象的名称。 说明 在错误处理后,使用 Clear 显式地清除 Err 对象。此
CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile source, destination[, overwrite] 参数 object 必选
Copy 方法 将指定的文件或文件夹从某位置复制到另一位置。 object.Copy destination[, overwrite] 参数 object 必选项。应为 File 或 F
Close 方法 关闭打开的 TextStream 文件。 object.Close object 应为 TextStream 对象的名称。 说明 下面例子举例说明如何使用 Close 方
BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) 参数 object 必选项。应为 FileSystemObject 对象的名称
GetFolder 方法 返回与指定的路径中某文件夹相应的 Folder 对象。 object.GetFolder(folderspec) 参数 object 必选项。应为 FileSy
GetFileName 方法 返回指定路径(不是指定驱动器路径部分)的最后一个文件或文件夹。 object.GetFileName(pathspec) 参数 object 必选项。应为
GetFile 方法 返回与指定路径中某文件相应的 File 对象。 object.GetFile(filespec) 参数 object 必选项。应为 FileSystemObject
GetExtensionName 方法 返回字符串,该字符串包含路径最后一个组成部分的扩展名。 object.GetExtensionName(path) 参数 object 必选项。应
GetDriveName 方法 返回包含指定路径中驱动器名的字符串。 object.GetDriveName(path) 参数 object 必选项。应为 FileSystemObjec
GetDrive 方法 返回与指定的路径中驱动器相对应的 Drive 对象。 object.GetDrive drivespec 参数 object 必选项。应为 FileSystemO
GetBaseName 方法 返回字符串,其中包含文件的基本名 (不带扩展名), 或者提供的路径说明中的文件夹。 object.GetBaseName(path) 参数 object 必
GetAbsolutePathName 方法 从提供的指定路径中返回完整且含义明确的路径。 object.GetAbsolutePathName(pathspec) 参数 object
FolderExists 方法 如果指定的文件夹存在,则返回 True;否则返回 False。 object.FolderExists(folderspec) 参数 object 必选项
FileExists 方法 如果指定的文件存在返回 True;否则返回 False。 object.FileExists(filespec) 参数 object 必选项。应为 FileS
我是一名优秀的程序员,十分优秀!