CSS常⽤属性

背景属性

CSS背景属性主要有以下⼏个:

background-color属性

该属性设置背景颜⾊:

<div class="box"></div>
.box
{
 width: 300px;
 height: 300px;
 background-color: palevioletred;
}

颜⾊值:

1、单词:red、green等;

2、十六进制:#000000、#ffffff

3、颜色通道:rgb(255,255,255),rgba(225,225,225,0.5)[注:rgba最后的0.5为透明度,越趋近于0越透明。其余部分与rgb一致。]

background-image属性

设置元素的背景图像。

<div class="box"></div>
.box{
 width: 600px;
 height: 600px;
 background-image: url("images/img1.jpg");
}

background-repeat属性

该属性设置如何平铺背景图像。

描述
repeat-x⽔平⽅向平铺
repeat-y垂直⽅向平铺
no-repeat不平铺
.box{
 width: 600px;
 height: 600px;
 background-image: url("images/img1.jpg");
 background-repeat: no-repeat;
}

background-size属性

该属性设置背景图像的⼤⼩。

 

.box{
 width: 600px;
 height: 600px;
 background-image: url("images/img1.jpg");
 background-repeat: no-repeat;
 background-size: 100% 100%;
}

background-position属性

该属性设置背景图像的起始位置,其默认值是:0% 0%。

描述
left top左上⻆为基准
left center左 中
left bottom左 下
right top右 上
right center右 中
right bottom右 下
center top中 上
center center中 中
center bottom中 下
x% x%百分⽐
.box{
 width: 600px;
 height: 600px;
 background-image: url("images/img1.jpg");
 background-repeat: no-repeat;
 background-position: center;
 }

background复合属性

background-image、background-repeat、background-position 其中background-size单独书写。

字体属性

CSS字体属性定义字体,加粗,⼤⼩,⽂字样式。

color

规定⽂本的颜⾊。

div{ color:red;}
div{ color:#ff0000;}
div{ color:rgb(255,0,0);}
div{ color:rgba(255,0,0,.5);}

font-size

设置⽂本的⼤⼩。

h1 {font-size:40px;}
h2 {font-size:30px;}
p {font-size:14px;}

font-weight

设置⽂本的粗细。

描述
100~900数值定义粗细
bold定义粗体
H1 {font-weight:normal;}
div{font-weight:bold;}
p{font-weight:900;}

font-family

font - family属性指定⼀个元素的字体。

p{
 font-family:"Microsoft YaHei","Simsun","SimHei";
}/*font - family属性指定⼀个元素的字体*/

⽂本属性

text-align

指定元素⽂本的⽔平对⻬⽅式。

描述
left左对齐
right右对齐
center居中对齐
h1 {text-align:center}/*居中对齐*/
h2 {text-align:left}/*左对齐*/
h3 {text-align:right}/*右对齐*/

text-decoration

text-decoration 属性规定添加到⽂本的修饰,下划线、上划线、删除线等。

描述
underline定义⽂本下划线
overline定义⽂本上划线
line-through定义穿过⽂本
h1 {text-decoration:overline} 
h2 {text-decoration:line-through} 
h3 {text-decoration:underline}

列表属性

list-style-type 属性

设置列表项标记的类型。

描述
none无标记
disc默认,实⼼圆
circle空⼼圆
square实⼼⽅块
ul.a {list-style-type: circle;}
ul.b {list-style-type: square;}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

单身理工男

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值