博主信息
博文 14
粉丝 0
评论 0
访问量 10577
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
position定位与登陆框
Bruce.lau
原创
527人浏览过

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>
批改老师:PHPzPHPz

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学