[零基础俯冲前端]CSS入门(2021.3.20打卡)

id和class选择器

如果你要在HTML元素中设置CSS样式,你需要在元素中设置id和class选择器

id选择器

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
<style>
#para1
{
     
     
	text-align:center;
	color:red;
} 
</style>
</head>

<body>
<p id="para1">Hello World!</p>
<p>这个段落不受该样式的影响。</p>
</body>
</html>

在这里插入图片描述

class选择题

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
<style>
.center
{
     
     
	text-align:center;
}
</style>
</head>

<body>
<h1 class="center">标题居中</h1>
<p class="center">段落居中。</p> 
</body>
</html>

在这里插入图片描述

css的创建

在昨天的博客中我门介绍过了

  1. 外部样式表
  2. 内部样式表
  3. 内联样式

css背景

background-color

background-image

background-repeat

设置定位与不平铺

background-attachment

背景图像是否固定或者随着页面的其余部分滚动

background-position

设置背景图像的起始位置

css列表

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
<style>
ul.a {
     
     list-style-type:circle;}
ul.b {
     
     list-style-type:square;}
ol.c {
     
     list-style-type:upper-roman;}
ol.d {
     
     list-style-type:lower-alpha;}
</style>
</head>

<body>
<p>无序列表实例:</p>

<ul class="a">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ul>

<ul class="b">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ul>

<p>有序列表实例:</p>

<ol class="c">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

<ol class="d">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Coca Cola</li>
</ol>

</body>
</html>

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_42136832/article/details/115027850