CSS之基础

it2022-05-20  68

css是英文Cascading Style Sheets的缩写,称为层叠样式表,用于对页面进行美化。存在方式有三种:元素内联、页面嵌入和外部引入,比较三种方式对优缺点。

语法:style = "key1:value1;key2:value2;"

在标签中使用style=‘xx:xxx;’在页面中嵌入<style type="text/css"></style>块引入外部css文件

必要性:美工会对页面的色彩搭配和图片的美化负责,开发人员则必须知道是如何实现的。

标签选择器

div{background-color:red;} <div></div>

定义一个div背景颜色,可以在div里设置大小和位置。

class选择器

.bd{background-color:red;} <div class='bd'></div>

定义一个标签,并且在div里调用定义的标签。

id选择器

#idselect{background-color:red;} <div id='idselect'></div>

关联选择器

#idselect p{background-color:red;} <div id='idselect'><p></p></div>

组合选择器

input,div,p{backfround-color:red;}

属性选择器

input[type='text']{width:100px; height:200px;}

 

转载于:https://www.cnblogs.com/wulaoer/p/5170371.html


最新回复(0)