我现在有 1 小时的 HTML、CSS 经验,并且对编程有更深入的理解,例如使用 java 脚本。所以请原谅我,如果我对如何在这里做某事一无所知。
我想创建我的 p5 画布,它也符合我的 CSS 规则。我该怎么做呢?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My website!</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="container">
<h1>My Website</h1>
<h2>It is all coming together.</h2>
<script type="text/javascript" src="p5.js"></script>
<script type="text/javascript" src="my_code.js"></script>
</div>
</body>
</html>
我的CSS:
body {
background-image: url("matt-walsh-tVkdGtEe2C4-unsplash.jpg");
background-repeat: no-repeat;
background-size: cover;
}
.container {
background-color: hsla(0, 0%, 50%, 0.8);
height: auto;
width: fit-content;
padding: 0px 250px;
}
h1 {
text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
font-size: 10vw;
font-family: Arial;
color: white;
text-align: center;
}
h2 {
text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
font-size: 5vw;
font-family: Arial;
color: white;
text-align: center;
}
p {
font-family: Arial;
color: black;
text-align: left;
max-width: 200vw;
}
script {
alignment: center;
}
为了完成起见:
function setup() {
createCanvas(400, 400);
}
function draw() {
if (mouseIsPressed) {
fill(0);
ellipse(mouseX, mouseY, 80, 80);
}
}
这将创建此页面:
慕虎7371278
相关分类