CSS的字体、文本和图像样式和例子

css字体样式属性:

font-family字体的类型
font-size字体的大小(常用单位px
font-weight字体的粗细(normal正常、bold加粗等)
font-style字体的倾斜(italic斜体、oblique倾斜等)

css的文本样式属性(常用):

text-align文本的水平对齐方式(centerleft等)
line-height行高(常用单位px
text-decoration

文本修饰效果(underline下划线、overline上划线、line-through删除线等)

text-indent段落的首行缩进
text-overflow文本的截断
first-letter首字下沉

text-transform

英文字母的大小写(uppercase全大写、lowercase全小写、capitalize每个英文首字母大写)
background-color文本的背景颜色

css的图像样式:

width、height图像的缩放
border图像边框样式
opacity图像的不透明度
background-image背景图像
background-repeat背景图像重复方式
background-position背景图像定位
background-attachment背景图像固定
background-size背景图像大小

例子:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <style>

        #p1{

            text-decoration: underline;

            text-align: left;

            text-transform: uppercase;

        }

        #p2{

            height: 20px;

            width: 400px;

            background-color: yellow;

            text-decoration: line-through;

            text-align: center;

            text-transform: lowercase;

        }

        #p3{

            text-decoration: overline;

            text-align: right;

            text-transform: capitalize;

        }

        #img1{

            height: 250px;

            width: 250px;

            border: 20px green dotted;

            background-color: gray;

            display: block;

        }

        h6{

            height: 300px;

            width: 500px;

            background-color: gray;

            background-repeat: no-repeat;

            background-size: 50% 50%;

            background-position: center top;

            background-image: url(./风景.jpg);

        }

    </style>

</head>

<body>

    <p id="p1">靠左对齐,下划线,大写字母</p>

    <p id="p2">居中对齐,删除线,小写字母</p>

    <p id="p3">靠右对齐,上划线,单词首大写字母</p>

    <img src="./风景.jpg" id="img1">

    <h6></h6>

</body>

</html>

运行结果:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值