CSS3样式-美化界面

2020-05-13  本文已影响0人  笑该动人d

一、字体样式

字体样式的基本属性

1.font-family属性

<!--
    Verdana 为设置的英文字体类型
    “楷体” 为设置的中文字体类型
-->
<style>
    p {
        font-family: Verdana, "楷体";
    }
</style>

2.font-size属性

单位
<style>
    body{
        font-size: 10px;
    }
    /* 正常设置字体大小  */
    h1 {
        font-size: 32px;
    }

    /*
        rem 单位基于 html 元素的字体大小
        默认通常为16px,2rem则相当于32px
    */
    h2 {
        font-size: 2rem;
    }

    /*
        em 单位可能受任何继承的父元素字体大小影响
        若未设置父类元素字体大小,则默认也为16px,2em则相当于32px
    */
    h3 {
        font-size: 2em;
    }
</style>  

3.font-style属性

<h1>标题1</h1>
<h2>标题2</h2>
<h3>标题3</h3>

4.font-weight属性

font-weight相关属性值

5.font属性

二、文本样式

文本样式的基本属性

1.color属性

填写颜色的几种方式

2.text-align属性 文本排版

text-align属性相关值

3.text-decoration属性 文本装饰

text-decoration属性相关值

4.vertical-align属性 垂直对齐方式

5.text-shadow 文本阴影

*呈现效果


阴影呈现效果

三、超链接伪类

1.伪类样式

2.使用CSS设置超链接

四、列表样式

1.列表类型(list-style-type)

例如,在一个无序列表中,列表项的标志 (marker) 是出现在各列表项旁边的圆点。在有序列表中,标志可能是字母、数字或另外某种计数体系中的一个符号。

要修改用于列表项的标志类型,可以使用属性 list-style-type

2.列表项图像(list-style-image)

有时,常规的标志是不够的。你可能想对各标志使用一个图像,这可以利用 list-style-image 属性做到:

    ul li {
        list-style-image: url(xxx.gif)
    }

只需要简单地使用一个 url() 值,就可以使用图像作为标志。

3.列表标志位置(list-style-position)

CSS2.1 可以确定标志出现在列表项内容之外还是内容内部。这是利用 list-style-position 完成的

4.简写列表样式(list-style)

为简单起见,可以将以上 3 个列表样式属性合并为一个方便的属性:list-style,就像这样:

    li {
        list-style: url(example.gif) square inside
    }

list-style 的值可以按任何顺序列出,而且这些值都可以忽略。只要提供了一个值,其它的就会填入其默认值。

五、背景样式

1.背景颜色(background-color)

2.背景图像(background-image)

3.背景定位(background-position)

        background-position: 10px 10px;
        background-position: 50% 50%; 
        background-position: left center;
背景定位属性值

4.背景重复方式(background-repeat)

属性值

5.背景属性(background)

设置背景属性值的顺序:背景颜色→背景图像→背景定位→背景重复方式

  background:#C00 url(../image/arrow-down.gif) 205px 10px no-repeat;

5.背景尺寸(background-size)

背景尺寸属性值

六、CSS3渐变

1.线性渐变(linear-gradient)

2.径直渐变

3.浏览器兼容性

兼容性图片
上一篇 下一篇

猜你喜欢

热点阅读