vscode
初次在VScode中写 HTML,遇到的一些小问题。
- !+TAB可以快速生成HTML框架代碼。
- 预览网页首先需要安装插件,找到安装插件的库,安装插件 View In Browser插件。
- vscode需要保存后在运行才可以生效的(默认ctrl+s)
- 下午写的代码(h5+css+js)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.header{
height: 100px;
width: 100%;
}
.center{
height: 400px;
width: 100%;
}
.footer{
height: 50px;
width: 100%;
}
</style>
<link rel="stylesheet" type="text/css" href="center.css">
</head>
<body>
<h1>Hello World!</h1>
<div class = "header" style="background-color :red;">
<label>header</label>
</div>
<div class = "center" style="background-color: yellow;">
<div class = "left" style="background-color:purple">
<label>left</label>
</div>
<div class = "right" style="background-color:brown">
<label>right</label>
</div>
</div>
<div class = "footer" id='footer' style="background-color: blue;">
<label>footer</label>
<input type="button" onclick="clickme()" value="click me">
</div>
<script>
function clickme(){
document.getElementById('footer').style.backgroundColor='black';
}
</script>
</body>
</html>
.left{
height: 100%;
width: 20%;
float: left;
}
.right{
height: 100%;
width: 70%;
float: right;
}

本文介绍了在VSCode中编写HTML的基本技巧,包括使用快捷键生成HTML框架,安装并使用ViewInBrowser插件预览网页,以及如何通过保存文件使更改生效。文中还提供了HTML、CSS和JavaScript结合使用的示例代码。

被折叠的 条评论
为什么被折叠?



