目录

margin:外边距
padding:内边距
border:边框
1)边框的粗细
2)边框的样式
3)边框的颜色
- html>
- <html lang="en" xmlns:th="http://www.thymeleaf.org">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- <style>
- body{
- /*body总有一个默认的外边距*/
- margin: 0px;
- }
- #box{
- width: 300px;
- /*粗细 样式 颜色*/
- border: 1px solid skyblue;
- }
- /*标题默认也有外边距*/
- h2{
- font-size: 16px;
- background-color: #8EC5FC;
- line-height: 30px;
- color: whitesmoke;
- margin: 0px;
- }
- form{
- background: blanchedalmond;
- }
- div:nth-of-type(1) input{
- border:3px solid black;
- }
- div:nth-of-type(2) input{
- border:3px dashed palegreen;
- }
- div:nth-of-type(3) input{
- border:3px dashed lightcoral;
- }
- style>
-
- head>
- <body>
- <div id="box">
- <h2>会员登录h2>
- <form action="#">
- <div>
- <span>用户名:span>
- <input type="text">
- div>
- <div>
- <span>密码:span>
- <input type="text">
- div>
- <div>
- <span>邮箱:span>
- <input type="text">
- div>
- form>
- div>
- body>
- html>
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
常见操作:初始化
测试圆角边框
- html>
- <html lang="en" xmlns:th="http://www.thymeleaf.org">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- <style>
- div{
- width: 50px;
- height: 50px;
- margin: 30px;
- background: paleturquoise;
- border-radius: 50px 0px 0px 0px;
- }
- img{
- border-radius: 85px;
- }
- style>
- head>
- <body>
- <div>div>
- <img src="images/a.PNG" alt="">
- body>
- html>
测试盒子阴影:
- html>
- <html lang="en" xmlns:th="http://www.thymeleaf.org">
- <head>
- <meta charset="UTF-8">
- <title>Titletitle>
- <style>
- img{
- border-radius:85px ;
- /*x轴偏移量 y轴偏移量 模糊半径 颜色*/
- box-shadow:10px 10px 100px yellow ;
- }
- style>
- head>
- <body>
- <div style="width: 1000px;height:1000px;display: block;text-align: center">
- <img src="images/a.PNG " alt="">
- div>
-
- body>
- html>