前言:
本文内容:背景图应用及渐变、盒子模型及边框使用
推荐免费CSS3基础讲解视频:【狂神说Java】CSS3最新教程快速入门通俗易懂_哔哩哔哩_bilibili
背景图片应用及渐变
背景图片
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <style> div{ width: 700px; height: 500px; border: 1px solid black; background-image: url("image/images.png");
} .div1{ background-repeat: repeat-x; } .div2,.div3{ background-repeat: no-repeat; }
</style>
|
列表样式美化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #nav{ width: 300px; } h1{ color: red; background: url("../image/down.jpg") 230px 15px no-repeat; }
ul li{ height: 30px; list-style: none; background: url("../image/up.jpg"); background-repeat: no-repeat; background-position: 230px,2px;
} a{ text-decoration: none; font-size: 14px; color: black; }
a:hover{ background: #b8b5b5; color: #e71111; }
|
颜色渐变
Grabient
GitHub - johnkorzhuk/grabient: UI to generate linear-gradients
1 2 3 4 5 6 7 8 9
| <style> body{ background-color: #8EC5FC; background-image: -webkit-linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%); background-image: -moz-linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%); background-image: -o-linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%); background-image: linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%); } </style>
|
盒子模型及边框使用
什么是盒子模型
margin:外边距
padding:内边距
border:边框
边框
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ margin: 0; padding: 0; text-decoration: none; } #box{ width: 300px; border: 1px solid red; } h2,form{ background-color: #D9AFD9; background-image: -webkit-linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%); background-image: -moz-linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%); background-image: -o-linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%); background-image: linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%); } div:nth-of-type(1) input{ border: 2px solid black; } div:nth-of-type(2) input{ border: 2px dashed black; } </style> </head> <body> <div id="box"> <h2>会员登录</h2> <form action="#"> <div> <span>账号:</span> <input type="text"> </div> <div> <span>密码:</span> <input type="password"> </div> <div> <span>邮箱:</span> <input type="email"> </div> <div> <input type="submit" value="登录"/> <input type="reset" value="取消"/> </div> </form> </div> </body> </html>
|