码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • css3-盒子模型、内外边距、圆角边框


    目录

    1.盒子模型及边框的应用

    1.1 什么是盒子

    1.2 什么是边框

    2.内外边距及div居中

    3.圆角边框及阴影


    1.盒子模型及边框的应用

    1.1 什么是盒子

    margin:外边距

    padding:内边距

    border:边框

    1.2 什么是边框

    1)边框的粗细

    2)边框的样式

    3)边框的颜色

    1. html>
    2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Titletitle>
    6. <style>
    7. body{
    8. /*body总有一个默认的外边距*/
    9. margin: 0px;
    10. }
    11. #box{
    12. width: 300px;
    13. /*粗细 样式 颜色*/
    14. border: 1px solid skyblue;
    15. }
    16. /*标题默认也有外边距*/
    17. h2{
    18. font-size: 16px;
    19. background-color: #8EC5FC;
    20. line-height: 30px;
    21. color: whitesmoke;
    22. margin: 0px;
    23. }
    24. form{
    25. background: blanchedalmond;
    26. }
    27. div:nth-of-type(1) input{
    28. border:3px solid black;
    29. }
    30. div:nth-of-type(2) input{
    31. border:3px dashed palegreen;
    32. }
    33. div:nth-of-type(3) input{
    34. border:3px dashed lightcoral;
    35. }
    36. style>
    37. head>
    38. <body>
    39. <div id="box">
    40. <h2>会员登录h2>
    41. <form action="#">
    42. <div>
    43. <span>用户名:span>
    44. <input type="text">
    45. div>
    46. <div>
    47. <span>密码:span>
    48. <input type="text">
    49. div>
    50. <div>
    51. <span>邮箱:span>
    52. <input type="text">
    53. div>
    54. form>
    55. div>
    56. body>
    57. html>

    2.内外边距及div居中

    margin-left/right/top/bottom–>表示四边,可分别设置,也可以同时设置如下

    margin:0 0 0 0/*分别表示上、右、下、左;从上开始顺时针*/
    /*例1:居中*/
    margin:0 auto /*auto表示左右自动*/
    /*例2:*/
    margin:4px/*表示上、右、下、左都为4px*/
    /*例3*/
    margin:10px 20px 30px/*表示上为10px,左右为20px,下为30px*/

    盒子的计算方式:
    margin+border+padding+内容的大小

    总结:
    body总有一个默认的外边距 margin:0
    常见操作:初始化

    3.圆角边框及阴影

    测试圆角边框

    1. html>
    2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Titletitle>
    6. <style>
    7. div{
    8. width: 50px;
    9. height: 50px;
    10. margin: 30px;
    11. background: paleturquoise;
    12. border-radius: 50px 0px 0px 0px;
    13. }
    14. img{
    15. border-radius: 85px;
    16. }
    17. style>
    18. head>
    19. <body>
    20. <div>div>
    21. <img src="images/a.PNG" alt="">
    22. body>
    23. html>

    测试盒子阴影:

    1. html>
    2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Titletitle>
    6. <style>
    7. img{
    8. border-radius:85px ;
    9. /*x轴偏移量 y轴偏移量 模糊半径 颜色*/
    10. box-shadow:10px 10px 100px yellow ;
    11. }
    12. style>
    13. head>
    14. <body>
    15. <div style="width: 1000px;height:1000px;display: block;text-align: center">
    16. <img src="images/a.PNG " alt="">
    17. div>
    18. body>
    19. html>
  • 相关阅读:
    快上车,LLM专列:想要的资源统统给你准备好了
    Sketch for mac v98.2最新版 修复了打开某些文档时导致 Sketch 崩溃的错误
    【MySQL进阶】深入理解B+树索引底层原理
    java程序员进阶必读书单
    基于bootstrap,企业内部管理系统后台框架前端源码,响应式布局
    Unity 3D 简易对象池
    要学习使用 calib3D 模块在图像中创建 3D 效果-姿势估计
    【MediaSoup---源码篇】(五)接收RTP数据的处理
    线性表与链表的详解
    《C++》继承
  • 原文地址:https://blog.csdn.net/qq_61727355/article/details/126585975
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号