[Zero-based dive front end] Introduction to CSS (2020.3.20 check-in)

id and class selector

If you want to set CSS styles in HTML elements, you need to set id and class selectors in the elements

id selector

<!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>

Insert picture description here

class multiple choice

<!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>

Insert picture description here

css creation

I introduced it in yesterday’s blog

  1. External style sheet
  2. Internal style sheet
  3. Inline style

css background

background-color

background-image

background-repeat

Set positioning and non-tiling

background-attachment

Whether the background image is fixed or scrolls with the rest of the page

background-position

Set the starting position of the background image

css list

<!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>

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42136832/article/details/115027850