博主信息
博文 25
粉丝 0
评论 0
访问量 16559
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
状态伪类与盒模型
PHui
原创
455人浏览过

1.伪类实战

html

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>用户注册</title>
  8. <link rel="stylesheet" href="css/fake.css"
  9. </head>
  10. <body>
  11. <form
  12. action=""
  13. method="post"
  14. enctype="application/x-www-form-urlencoded"
  15. target="_blank"
  16. id="rigster"
  17. >
  18. <fieldset>
  19. <legend>用户注册</legend>
  20. <div class="username">
  21. <label for="uname">用户名:</label>
  22. <input
  23. type="text"
  24. id="uname"
  25. name="username"
  26. placeholder="请输入用户名"
  27. required
  28. autofocus
  29. />
  30. </div>
  31. <div class="password">
  32. <label for="psd">密码:</label>
  33. <input
  34. type="password"
  35. id="psd"
  36. name="password"
  37. placeholder="请输入密码"
  38. required
  39. />
  40. </div>
  41. <div class="email">
  42. <label for="myemail">邮箱:</label>
  43. <input
  44. type="email"
  45. id="myemail"
  46. name="email"
  47. placeholder="格式xxxx@xx.com"
  48. required
  49. />
  50. </div>
  51. <div class="remem">
  52. <input type="checkbox" id="rem" name="remember" checked />
  53. <label for="rem">记住我</label>
  54. </div>
  55. <button>提交</button>
  56. </fieldset>
  57. </form>
  58. </body>
  59. </html>

css

  1. label {
  2. width: 52px;
  3. height: 35px;
  4. text-align: left;
  5. display: inline-block;
  6. }
  7. fieldset {
  8. width: 250px;
  9. }
  10. button {
  11. width: 230px;
  12. }
  13. fieldset legend {
  14. text-align: center;
  15. }
  16. /* ? 匹配到获取焦点的元素 */
  17. fieldset :focus {
  18. background-color: gainsboro;
  19. transition: 0.8s;
  20. }
  21. /* ? 匹配被选中的复选框元素 */
  22. input[type="checkbox"]:checked + label {
  23. color: red;
  24. }

效果

2.盒模型

盒模型五个核心属性:

1.width: 宽度
2.height: 高度
3.padding: 内边距
4.border: 边框
5.margin: 外边距

  1. <div class="box"></div>
  1. .box {
  2. width: 200px;
  3. height: 200px;
  4. padding: 10px;
  5. border: 2px solid red;
  6. margin: 10px;
  7. box-sizing: border-box;
  8. background-clip: content-box;
  9. background-color: yellow;
  10. }


box-sizing: 定义如何计算一个元素的总宽度和总高度

  1. content-box:任何边框和内边距的宽度都会被增加到最后绘制出来的元素宽度中
  2. bored-box:设置的边框和内边距的值是包含在 width 内的。
    width(宽度) + padding(内边距) + border(边框) = 元素实际宽度
    height(高度) + padding(内边距) + border(边框) = 元素实际高度
    注:border-box 不包含 margin。
批改老师: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+教程免费学