总结HTML和css以及JavaScript的注释方式,并说明注释的作用

8 篇文章 0 订阅


1.HTML的注释方法

<!--注释的内容-->

使用的位置:

1)一般会使用在一些主要节点标签结束的后边,如:

.....................................

2)使用在一些循环的结束的后边,如:

111111

222222

333333

这一切都是为了程序在嵌套的时候更加方便、明了

 

CSS的注释方法 

/* 注释内容 */

一般会使用在定义某个模块样式的上边,说明这段样式是作用于哪段模块,如:

/*头部导航*/
.header{.....}

/*尾部导航*/
.auto{...}

3JavaScript注释

1.//单行备注

2./*注释内容*/(多行注释)

一般将注释添加在某段功能函数的上边,说明函数的功能、作者、作者信息、修改时间。

其实总的来说注释就是在一系列代码之后说明一下自己的思路,想法,以方便那些阅读你代码的人看上去能一目了然,也能够在一个月,两个月之后,甚至更久时间之后能够回忆起当初为什么这么写,注释是个利人利己的好方法

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
我可以回答这个问题。以下是一个简单的示例代码,用于使用 HTMLCSSJavaScript 来设计页面布局和样式,并实现登录功能。 HTML 代码: ``` <!DOCTYPE html> <html> <head> <title>登录页面</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="login-box"> <h2>登录</h2> <form> <div class="user-box"> <input type="text" name="username" required=""> <label>用户名</label> </div> <div class="user-box"> <input type="password" name="password" required=""> <label>密码</label> </div> <input type="submit" name="" value="登录"> </form> </div> <script src="script.js"></script> </body> </html> ``` CSS 代码: ``` * { margin: ; padding: ; box-sizing: border-box; } body { font-family: sans-serif; background: #34495e; } .login-box { width: 280px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #191919; padding: 40px; border-radius: 10px; box-shadow: 20px rgba(, , , .2); } .login-box h2 { color: #fff; text-align: center; margin-bottom: 30px; } .login-box .user-box { position: relative; } .login-box .user-box input { width: 100%; padding: 10px ; font-size: 16px; color: #fff; margin-bottom: 30px; border: none; border-bottom: 1px solid #fff; outline: none; background: transparent; } .login-box .user-box label { position: absolute; top: ; left: ; padding: 10px ; font-size: 16px; color: #fff; pointer-events: none; transition: .5s; } .login-box .user-box input:focus ~ label, .login-box .user-box input:valid ~ label { top: -20px; left: ; color: #03a9f4; font-size: 12px; } .login-box input[type="submit"] { background: transparent; border: none; outline: none; color: #fff; background: #03a9f4; padding: 10px 20px; cursor: pointer; border-radius: 5px; } .login-box input[type="submit"]:hover { background: #1cb1f5; } ``` JavaScript 代码: ``` const form = document.querySelector('form'); const username = document.querySelector('input[name="username"]'); const password = document.querySelector('input[name="password"]'); form.addEventListener('submit', e => { e.preventDefault(); if (username.value === 'admin' && password.value === 'password') { alert('登录成功!'); } else { alert('用户名或密码错误!'); } }); ``` 使用说明: 1. 将以上代码分别保存为 `index.html`、`style.css` 和 `script.js`。 2. 将这三个文件放在同一个文件夹中。 3. 双击打开 `index.html` 文件,即可在浏览器中查看登录页面。 4. 在用户名和密码输入框中输入正确的用户名和密码,点击登录按钮即可登录成功。 5. 如果用户名或密码错误,会弹出提示框提示错误信息。 注释: 以上代码中已经添加了注释,用于说明代码的作用和实现方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值