css怎么实现首字母下沉效果


本文摘自PHP中文网,作者V,侵删。

css实现首字母下沉效果的方法:可以通过使用first-letter伪类选择器来实现,如【.contain p:first-letter{}】。first-letter伪类选择器用来指定元素第一个字母的样式。

可以通过使用css的first-letter伪类选择器来实现首字母下沉效果。

(学习视频分享:css视频教程)

相关介绍:

:first-letter选择器用来指定元素第一个字母的样式。

HTML代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Document</title>

    <style>

        body {

            background-color: #FFFFFF;

            color: #595959;

        }

        .contain {

            width: 150px;

        }

        .contain p {

            font: 80%/1.6 Verdana, Geneva, Arial, Helvetica, sans-serif;

        }

        .contain p:first-letter {

            font-size: 2em;

            padding: 0.1em;

            color: #000000;

            vertical-align: middle;

        }

        .contain p:first-line {

            color: red;

        }

        .contain p:first-child:first-letter {

            color: red;

        }

        .contain p:first-child:first-line {

            color: inherit;

        }

    </style>

</head>

<body>

    <div>

        <p>This is a test article. This is a test article.</p>

        <p>This is a test article. This is a test article.</p>

        <p>这是一个测试</p>

    </div>

</body>

</html>

实现效果:

50b22351219d578650feee44ea44148.png

相关推荐:CSS教程

以上就是css怎么实现首字母下沉效果的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

css中怎么把图片设置居右

css怎么隐藏滚动条

css 如何实现让文字滑入的方式

css如何写绝对路径

css设置字体大小的属性名是什么

css unicode-bidi属性怎么用

css哪些属性可以继承

css如何设置字体下划线

css box-direction属性怎么用

css3核心知识点的小结(代码示例)

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...