Blogger Information
Blog 14
fans 0
comment 0
visits 7512
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
position定位与登陆框
Bruce.lau
Original
376 people have browsed it

position定位与登陆框

效果图
点击登陆
登陆后

顶部导航栏
  1. <header>
  2. <div class="title">Bruce的栏目首页</div>
  3. <button class="login-btu" @click="showme">登陆</button>
  4. </header>
登录框
  1. <div class="login-background" v-if="show">
  2. <form class="login-form">
  3. <div class="input">
  4. <div>
  5. <label for="username">账号</label>
  6. <input type="text" name="username" placeholder="请输入账号">
  7. </div>
  8. <div>
  9. <label for="password">密码</label>
  10. <input type="password" name="password" placeholder="请输入账号">
  11. </div>
  12. <button @click="login">登陆</button>
  13. </div>
  14. </form>
  15. </div>

CSS样式

关键点:
1.背景position属性值为absolute,top,left,right,botton值为0
2.登陆框position属性值为absolute

  1. <style>
  2. * {
  3. margin: 0px;
  4. border: 0px;
  5. box-sizing: border-box;
  6. }
  7. header {
  8. display: flex;
  9. width: 100vw;
  10. height: 60px;
  11. background-color: azure;
  12. }
  13. header .title {
  14. font-size: larger;
  15. width: 100vw;
  16. line-height: 60px;
  17. }
  18. header>button {
  19. font-size: smaller;
  20. position: absolute;
  21. width: 60px;
  22. height: 26px;
  23. padding: 0px;
  24. right: 20px;
  25. top: 20px;
  26. }
  27. .login-background {
  28. background-color: rgba(222, 215, 214, 0.5);
  29. position: absolute;
  30. width: 100%;
  31. top: 0px;
  32. left: 0px;
  33. right: 0px;
  34. bottom: 0px;
  35. }
  36. .login-form {
  37. width: 400px;
  38. height: 300px;
  39. background-color: bisque;
  40. position: absolute;
  41. top: 300px;
  42. left: 450px;
  43. text-align: center;
  44. }
  45. .login-form .input {
  46. width: 100%;
  47. height: auto;
  48. line-height: 100px;
  49. }
  50. .login-form .input div{
  51. width: 100%;
  52. height: 60px;
  53. line-height: 100px;
  54. }
  55. </style>

使用VUE v-if指令完成点击登陆按钮弹出输入框即可

  1. <script>
  2. const app = {
  3. data() {
  4. return {
  5. show: 0
  6. }
  7. },
  8. methods: {
  9. showme() {
  10. this.show = 1
  11. },
  12. login() {
  13. alert("login ok")
  14. }
  15. }
  16. }
  17. Vue.createApp(app).mount('#app')
  18. </script>
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