Blogger Information
Blog 17
fans 0
comment 0
visits 8215
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
简单留言板练习
想做一个躺平的程序员
Original
415 people have browsed it

登录页面

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>登录表单</title>
  7. <style>
  8. body{
  9. /* 将浏览器的视口改变为 灰色 */
  10. background-color:silver
  11. }
  12. .form{
  13. /* 设置为固定定位 */
  14. position: fixed;
  15. top: 15rem;
  16. left: 28rem;
  17. background-color: skyblue;
  18. border-radius: .3rem;
  19. width: 300px;
  20. height: 130px;
  21. }
  22. .form .form-title{
  23. /* //设置为网格容器,三行1列,水平和垂直居中 */
  24. display: grid;
  25. grid-template-rows: repeat(3,1fr);
  26. place-items: center;
  27. outline: none;
  28. }
  29. .form .form-title legend{
  30. margin: auto 0;
  31. outline: none;
  32. /* 文本居中 */
  33. text-align: center;
  34. outline: solid skyblue;
  35. font-weight: bold;
  36. }
  37. .form .form-title .item{
  38. margin-bottom: .3rem;
  39. }
  40. .form .form-title .item input:hover{
  41. /* //鼠标移动到input控件中,改变样式 */
  42. box-shadow: .1rem .1rem .1rem skyblue;
  43. outline: none;
  44. }
  45. .form .form-title .item input{
  46. border-radius: .2rem;
  47. }
  48. .form .form-title .item button{
  49. border-radius: .2rem;
  50. padding: 0 .6rem;
  51. }
  52. .form .form-title .item a{
  53. /* 下划线取消 */
  54. text-decoration: none;
  55. border-radius: .2rem;
  56. padding: 0 .6rem .3rem;
  57. background-color: cadetblue;
  58. }
  59. .form .form-title .item a:hover{
  60. font-weight: bold;
  61. }
  62. </style>
  63. </head>
  64. <body>
  65. <form action="php" method="POST" class="form">
  66. <fieldset class="form-title">
  67. <legend>请登录</legend>
  68. <div class="item">
  69. <label for="username">用户名:</label>
  70. <input type="text" name="username" id="username" required placeholder="请输入用户名" >
  71. </div>
  72. <div class="item">
  73. <label for="">email:&nbsp;</label>
  74. <input type="email" name="useremail" id="useremail" required placeholder="请输入邮箱" >
  75. </div>
  76. <div class="item">
  77. <a href="#" onclick="add()">登录</a>
  78. </div>
  79. </fieldset>
  80. </form>
  81. </body>
  82. <script>
  83. function add(){
  84. const username=document.querySelector("#username").value;
  85. const useremail=document.querySelector("#useremail").value;
  86. if(username!='123123' && useremail!="123123@qq.com"){
  87. alert("用户名或邮箱错误");
  88. return false;
  89. }
  90. window.location.href="dome4.html";
  91. }
  92. </script>
  93. </html>

点击登录跳转到留言页面

留言板

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <style>
  9. body{
  10. background-color: silver;
  11. }
  12. .main{
  13. width: 300px;
  14. /* 固定定位 */
  15. position: fixed;
  16. top: 5rem;
  17. left: 27rem;
  18. background-color: white;
  19. border-radius: .3rem;
  20. display: grid;
  21. grid-template-rows: repeat(2,1fr);
  22. place-items: center;
  23. }
  24. .main .LeaveWord{
  25. width: 200px;
  26. margin-top: .2rem;
  27. border:.1rem solid cadetblue;
  28. border-radius: .1rem;
  29. }
  30. a{
  31. margin-left: 1rem;
  32. text-decoration: none;
  33. padding: 0 .1rem;
  34. background-color: skyblue;
  35. }
  36. li{
  37. padding-right: 11rem;
  38. list-style: none;
  39. }
  40. </style>
  41. <body>
  42. <div class="main">
  43. <input type="text" name="" id="" class="LeaveWord" placeholder="请输入留言" onkeydown="tianjia(event)">
  44. <ul class="list"></ul>
  45. </div>
  46. </body>
  47. <script>
  48. function tianjia(event){
  49. //当按下的按键等于回车键是进入判断体
  50. if(event.key=='Enter'){
  51. //获取输入框的值
  52. const inp=document.querySelector('input');
  53. const value=inp.value;
  54. // 创建 li元素
  55. const li=document.createElement('li');
  56. //将输入框的值赋给li,并加一个删除按钮
  57. li.innerHTML=value+"<a href=\"#\" onclick=\"del(this.parentNode)\" >删除</a>";
  58. //获取ul节点
  59. const ul=document.querySelector('.list');
  60. ul.insertAdjacentElement("afterbegin",li);
  61. inp.value=null;
  62. }
  63. }
  64. function del(element){
  65. console.log(element);
  66. //删除当前元素的父节点
  67. element.remove();
  68. }
  69. </script>
  70. </html>

留言板页面效果

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:可以,联动起来就慢慢完整了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post