负责页面显示的效果
style
<div style="width: 200px;height: 100px;background-color: red">这个是div标签</div>
style1
head
中定义style
标签<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS学习</title>
<style type="text/css">
.box1 {
width: 200px;
height: 100px;
background-color: green;
}
</style>
</head>
<body>
<div class="box1">这个是div2标签</div>
</body>
</html>
style2
link
一个css
文件<link rel="stylesheet" href="css/0830.css">
css/0830.css
文件:
/*注释*/
.box2 {
width: 200px;
height: 100px;
background-color: blue;
}
style3
CSS规则:选择器+一条或者多条声明
h1
{color:red;font-size:14px;}
h1
:选择器
color:red;
:声明
color
:属性
red
:值
<style type="text/css">
body {
background-color: blue;
}
</style>
标签选择器
.
<div class="box1">登录</div>
.box1 {
background: rgba(255, 195, 160, 0.5);
color: white;
font: bold 22px/30px 'Monaco';
text-align: center;
}
类选择器
#
<div id="b2">div2</div>
#b2 {
text-align: center;
font: normal 36px/60px 'Monaco';
}
id选择器
<div name="div3">div3</div>
div[name]{
color: red;
}
属性选择器
<div class="box2">
<div>
<span><i>Hello</i></span>
<i>Python</i>
</div>
</div>
.box2 div span{
color: green;
}
层级选择
选择多组元素
.box2, .box1 {
font: normal 36px/60px 'Monaco';
}
active focus hover:重要 link Visited
鼠标放上去生效
.box1:hover{
color: red;
}
鼠标放上去之前

背景色:background-color: blue;
背景图片:background-image: url("image/IMG_3609.JPG");
不平铺:background-repeat: no-repeat;
水平居中:background-position: center;
顶部:background-position: top;
blue
rgb(111, 222, 333)
rgba(111, 222, 333, 50)
http://tool.oschina.net/commons?type=3
image-20190830203508938
#FF0000
在Pycharm中直接选择
颜色选择器
设置顺序:是否加粗 字号/行高 字体;
font: bold 22px/30px 'Monaco';
文字居中:text-align: center;
规定了元素框处理元素内容,内边框,边框,外边距
CSS模型框
内边距:padding
外边距:margin
传入顺序:上右下左「顺时针」
边框线:border
.box1 {
width: 300px;
height: 150px;
background: aqua;
padding: 10px;
border: solid 2px blue;
margin: 80px;
}
盒子
盒子显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<style type="text/css">
body {
background: #396b94 url("image/IMG_3609.JPG") center no-repeat;
}
.login_box {
width: 520px;
height: 300px;
margin: 15% auto;
background: rgba(0, 0, 0, 0.25);
text-align: center;
border-radius: 8px;
}
.login_title {
color: #ffffff;
font: bold 22px/40px 'Microsoft Sans Serif';
padding-top: 20px;
}
.input_text {
height: 40px;
margin: 20px auto;
width: 60%;
border-radius: 8px;
}
.btn {
height: 100%;
width: 100%;
font: bold 22px/40px 'Microsoft Sans Serif';
background: #396b94;
color: white;
border: 0;
border-radius: 8px;
}
.input {
height: 100%;
width: 100%;
font: bold 18px/40px 'Microsoft Sans Serif';
border-radius: 8px;
border: solid 0.1px #57dbff;
text-indent: 20px;
}
</style>
</head>
<body>
<div class="login_box">
<div class="login_title">管理员登录</div>
<form action="">
<div class="input_text">
<input type="text" class="input" placeholder="请输入账号">
</div>
<div class="input_text">
<input type="password" class="input" placeholder="请输入密码">
</div>
<div class="input_text">
<input type="submit" class="btn" value="点击登录">
</div>
</form>
</div>
</body>
</html>
登录页面