使用js// 1、加载页面后,呈现蓝色填充文字“敲回车看好戏”(见常量START_TEXT), // 字体大小为46像素(TEXT_SIZE); // 2、敲击键盘回车后,逐步出现戴口罩的小女孩(images/ex2-1.jpg); // 3、小女孩图像显示完整后,过1秒后出现1米小剧场的漫画图(images/ex2-2.jpg); // 4、1秒后,出现蓝色填充的“谢谢观看”文字(见常量END_TEXT); // 5、效果请见demo2(视频演示)。
时间: 2023-03-30 13:04:34 浏览: 82
这是一个关于使用 JavaScript 实现页面效果的问题。以下是实现步骤:
1. 在页面加载后,使用 JavaScript 创建一个蓝色填充文字“敲回车看好戏”,字体大小为 46 像素。
2. 监听键盘事件,当用户敲击回车键时,逐步显示戴口罩的小女孩的图像(images/ex2-1.jpg)。
3. 当小女孩图像完整显示后,等待 1 秒后,显示 1 米小剧场的漫画图(images/ex2-2.jpg)。
4. 再等待 1 秒后,显示蓝色填充的“谢谢观看”文字。
5. 效果请见 demo2。
希望这个回答能够帮到你。
相关问题
js中// 1、加载页面后,呈现蓝色填充文字“敲回车看好戏”(见常量START_TEXT), // 字体大小为46像素(TEXT_SIZE); // 2、敲击键盘回车后,逐步出现戴口罩的小女孩(images/ex2-1.jpg); // 3、小女孩图像显示完整后,过1秒后出现1米小剧场的漫画图(images/ex2-2.jpg); // 4、1秒后,出现蓝色填充的“谢谢观看”文字(见常量END_TEXT);
这是一个关于 JavaScript 的问题,我可以回答。根据您的描述,可以使用以下代码实现:
```javascript
const START_TEXT = "敲回车看好戏";
const TEXT_SIZE = "46px";
const END_TEXT = "谢谢观看";
// 加载页面后,呈现蓝色填充文字“敲回车看好戏”,字体大小为46像素
document.body.style.backgroundColor = "blue";
const start = document.createElement("h1");
start.textContent = START_TEXT;
start.style.fontSize = TEXT_SIZE;
start.style.color = "white";
document.body.appendChild(start);
// 敲击键盘回车后,逐步出现戴口罩的小女孩
document.addEventListener("keydown", (event) => {
if (event.code === "Enter") {
const girl = document.createElement("img");
girl.src = "images/ex2-1.jpg";
girl.style.opacity = ;
document.body.appendChild(girl);
let opacity = ;
const intervalId = setInterval(() => {
opacity += .1;
girl.style.opacity = opacity;
if (opacity >= 1) {
clearInterval(intervalId);
// 小女孩图像显示完整后,过1秒后出现1米小剧场的漫画图
setTimeout(() => {
const theater = document.createElement("img");
theater.src = "images/ex2-2.jpg";
document.body.appendChild(theater);
// 1秒后,出现蓝色填充的“谢谢观看”文字
setTimeout(() => {
const end = document.createElement("h1");
end.textContent = END_TEXT;
end.style.fontSize = TEXT_SIZE;
end.style.color = "white";
document.body.appendChild(end);
}, 100);
}, 100);
}
}, 100);
}
});
```
使用js// 1、加载页面后,呈现蓝色填充文字“敲回车看好戏”(见常量START_TEXT), // 字体大小为46像素(TEXT_SIZE); // 2、敲击键盘回车后,逐步出现戴口罩的小女孩(images/ex2-1.jpg); // 3、小女孩图像显示完整后,过1秒后出现1米小剧场的漫画图(images/ex2-2.jpg); // 4、1秒后,出现蓝色填充的“谢谢观看”文字(见常量END_TEXT); // 5、效果请见demo2(视频演示)。
可以回答这个问题。以下是实现该效果的代码:
const START_TEXT = "敲回车看好戏";
const TEXT_SIZE = "46px";
const END_TEXT = "谢谢观看";
// 加载页面后,呈现蓝色填充文字“敲回车看好戏”
const startText = document.createElement("div");
startText.innerText = START_TEXT;
startText.style.color = "blue";
startText.style.fontSize = TEXT_SIZE;
document.body.appendChild(startText);
// 敲击键盘回车后,逐步出现戴口罩的小女孩
document.addEventListener("keydown", function(event) {
if (event.code === "Enter") {
const girlImage = document.createElement("img");
girlImage.src = "images/ex2-1.jpg";
girlImage.style.opacity = ;
document.body.appendChild(girlImage);
let opacity = ;
const intervalId = setInterval(function() {
opacity += .1;
girlImage.style.opacity = opacity;
if (opacity >= 1) {
clearInterval(intervalId);
// 小女孩图像显示完整后,过1秒后出现1米小剧场的漫画图
setTimeout(function() {
const theaterImage = document.createElement("img");
theaterImage.src = "images/ex2-2.jpg";
theaterImage.style.opacity = ;
document.body.appendChild(theaterImage);
let opacity = ;
const intervalId = setInterval(function() {
opacity += .1;
theaterImage.style.opacity = opacity;
if (opacity >= 1) {
clearInterval(intervalId);
// 1秒后,出现蓝色填充的“谢谢观看”文字
setTimeout(function() {
const endText = document.createElement("div");
endText.innerText = END_TEXT;
endText.style.color = "blue";
endText.style.fontSize = TEXT_SIZE;
endText.style.opacity = ;
document.body.appendChild(endText);
let opacity = ;
const intervalId = setInterval(function() {
opacity += .1;
endText.style.opacity = opacity;
if (opacity >= 1) {
clearInterval(intervalId);
}
}, 100);
}, 100);
}
}, 100);
}, 100);
}
}, 100);
}
});
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)