day01 css的引入方式 基本选择器 高级选择器 reset.css文件
一.表现标准:CSS
css: cascading style sheet : 层叠样式表
作用: 修饰网页结构
1.css的三种引入方式:
1).行内样式 <p style="color: red; font-size: 30px">文字</p>
2).内接样式 <style type="text/css"> </style>
3).外接样式 <link rel="stylesheet" href="./index.css">
三种方式的优先级:行内样式的优先级最高, 然后内接和外接, 这俩谁写在后面谁的优先级高
外接js:<script type="text/javascript" src="./index.js"></script>
color: 字体的颜色
font-size: 字体的大小
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="./index.css">
<style type="text/css">
span{
color: green;
font-size: 50px;
}
</style>
<script type="text/javascript" src="./index.js"></script>
</head>
<body>
<p style="color: red; font-size: 30px">bajieaishuishui</p> <span>八戒</span>
</body>
</html>
2.css的基本选择器
1).标签选择器: 直接标签名,选择的是所有有共性的
2).类选择器: .类名,选择的是所有有共性的,class写的时候可以有多个用空格分隔
3).id选择器: #id名,选择的是有特性的
4).通配符选择器: 用*号: 选中页面中所有标签. 在工作中不要用: 选中所有是有消耗的, 用什么?用reset.css 重置样式
把li前面的小圆点干掉,给父标签ul加属性
list-style: none;
去掉a 超链接下面的下滑线(注:其他标签默认没有下划线不用去)
text-decoration: none; (decoration 装饰)
用span伪造一个超链接,加颜色, 加下划线, 加小手
span{
color: blue;
text-decoration: underline;
cursor: pointer; #(光标: 指针)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="./reset.css">
<style>
p{
color: red;
}
ul{
list-style: none;
}
.active{
color: blueviolet;
}
.large{
font-size: 40px;
}
#p1{
color: yellow;
}
#p2{
color: green;
}
/**{*/
/*padding: 0;*/
/*margin: 0;*/
/*}*/
a{
text-decoration: none;
}
.baidu{
color: blue;
text-decoration: underline;
cursor: pointer;
}
</style>
</head>
<body>
<p id="p1">八戒爱谁谁</p>
<p>八戒爱谁谁1</p>
<p id="p2">八戒爱谁谁2</p>
<p>八戒爱谁谁3</p>
<p>八戒爱谁谁4</p>
<ul>
<li class="active large">
bajie
</li>
<li>
大唐
</li>
</ul>
<ul>
<li class="active">
wukong
</li>
</ul>
<a href="http://www.baidu.com/">百度一下</a>
<span class="baidu">百度一下</span>
</body>
</html>
3.css的高级选择器
1).组合选择器: ul,ol 多个选择器,逗号分隔
2).重置input样式,先隐藏边框,再设置边框 (外边距: margin, 内边距: padding, 边框: border)
input{
border: none; /*隐藏边框 nono换成 0 也可以 */
/*width: 100px;*/ /*如果不设置宽高, 就自适应前面字体的宽高*/
/*height: 30px;*/
border: 1px solid red; /*自定义边框, 宽度,样式,颜色三要素*/
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
ul,ol{
list-style-type: none;
}
input{
border: none;
/*width: 100px;*/
/*height: 30px;*/
font-size: 40px;
border: 1px solid red;
}
</style>
</head>
<body>
<ul>
<li class="active">
wukong
</li>
</ul>
<span class="baidu">百度一下</span>
<input type="text">
<ol>
<li>
one
</li>
<li>
two
</li>
</ol>
</body>
</html>
二.reset.css 文件
https://www.w3school.com.cn/ w3c标准的各种协议
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
内容总结
1.css
三种引入方式
行内样式> 内接样式, 外接样式
@import url()
link
基本选择器:
作用: 选中标签,设置属性
标签选择器
类名选择器
id选择器:未来与js有很大关联
通配符选择器
高级选择器:
组合选择器