css即层叠样式表,网站的美化师
【CSS的基本语法】
CSS的基本语法通常包含两个部分:一个是选择器,一个声明.

  • 选择器{属性:属性值;属性:属性值…}
    h1{color:yellow;font-size:20px;}
    引入方式:
   行内样式:直接在HTML的元素上使用style属性设置CSS.
        			<h1 style="color:red;font-size:200px ;">标题</h1>
        	页面内样式:在HTML的<head>标签中使用<style>标签设置CSS.
        		<style>
        			h1{
        				color:blue;
        				font-size: 40px;
        			}
        		</style>
        
        	外部样式:单独定一个.css的文件.在HTML中引入该CSS文件.  
       			 <link href="../../css/demo1.css" rel="stylesheet" type="text/css" />

css选择器:

【CSS的选择器】
	元素选择器:
div{
	border:1px solid blue;
	width:40px;
	height:45px;
}
	ID选择器:
#d1{
	border:2px solid red;
}
	类选择器:
.divClass{
	border:2px solid yellow;
}
	属性选择器:
		<style>
			input[type="text"]{
				background-color: red;
			}
		</style>

	后代选择器:
div span 查找的是所有div中的所有的span元素.
h1 strong{
   color:red;
}
		<h1>
			This is <strong>very</strong> <strong>very</strong> important.
		</h1>
		
		<h1>This is 
			<strong>very</strong>
			<em>really 
				<strong>very</strong>
			</em> 
				important.
		</h1>
	子元素选择器:
div > span找这个div中的第一层级的span元素.
h1 > strong{
   color:red;
}
		<h1>
			This is <strong>very</strong> <strong>very</strong> important.
		</h1>
		
		<h1>This is 
			<strong>very</strong>
			<em>really 
				<strong>very</strong>
			</em> 
				important.
		</h1>
	并列选择器:
选择器,选择器{
}

使用float属性可以完成DIV的浮动.
清除浮动效果:使用clear属性进行清除:
化妆师CSS
化妆师CSS
化妆师CSS
化妆师CSS
化妆师CSS
【CSS中的定位】
position属性设置定位:

  • relative:相对定位
  • absolute:绝对定位
    使用另外两个属性:left,top
    超链接的伪类
    化妆师CSS

相关文章:

  • 2022-12-23
  • 2021-10-17
  • 2021-11-26
  • 2022-12-23
  • 2022-01-19
  • 2021-07-05
  • 2021-09-18
  • 2021-09-06
猜你喜欢
  • 2021-08-18
  • 2021-07-31
  • 2021-12-03
  • 2022-01-14
  • 2021-12-21
  • 2021-05-04
  • 2021-11-15
相关资源
相似解决方案