我有一个来自Codepen的动画背景(下面的链接)但是我无法让我的文本浮动在背景的前面。因为我不认为这将有助于CSS - 制作动画背景的内容
Codepen我没有包括JS:https://codepen.io/zessx/pen/ZGBMXZ
截图:https://gyazo.com/37568fdb9681e4c9d67d4d88fc7658ba
我一直在使用的z-index和使用心不是帮助是绝对位置尝试。
Index.html
注:我已删除的代码是无关紧要的
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="js/index.js"></script>
</head>
<body>
<div id="bg"></div>
<div class="content w3-content" style="width: 80%;margin-left: 10%;">
<h1 class="font w3-jumbo w3-text-black">MOLLY URS</h1>
</div>
</body>
</html>
style.css
.bg {
z-index: 1;
background: -webkit-radial-gradient(center ellipse, #721B94 0%, #210627 100%) no-repeat center center fixed;
background: radial-gradient(ellipse at center, #721B94 0%, #210627 100%);
overflow: hidden;
}
body {
margin: 0;
}
.content {
position: absolute;
z-index: 100;
overflow: hidden;
}
我看不到你的'.content'格当我查看codepen的来源。 – WizardCoder
对不起,我没有解释,我使用的codepen代码,codepen是我的代码 –
没问题。 Joseph Marikle已经回答了你的问题,并且我已经添加了一个codepen作为对该答案的评论,以帮助你理解问题。 https://stackoverflow.com/a/44553245/8085668。 – WizardCoder