css writing-mode属性怎么用


本文摘自PHP中文网,作者青灯夜游,侵删。

css writing-mode属性定义了文本在水平或垂直方向上如何排布,用来控制文本的展示方向,以便可以从上到下或从左到右读取,具体取决于语言。西方语言一般都是 lr-tb 的书写方式,但是亚洲语言 lr-tb | tb-rl 的书写方式都有。

css writing-mode属性怎么用

writing-mode 属性定义了文本在水平或垂直方向上如何排布。

语法:

1

writing-mode: horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr

属性值:

● horizontal-tb:水平方向自上而下的书写方式。即 left-right-top-bottom

● vertical-rl:垂直方向自右而左的书写方式。即 top-bottom-right-left

● vertical-lr:垂直方向内内容从上到下,水平方向从左到右

● sideways-rl:内容垂直方向从上到下排列

● sideways-lr:内容垂直方向从下到上排列

说明:

writing-mode属性设置或检索对象的内容块固有的书写方向。西方语言一般都是 lr-tb 的书写方式,但是亚洲语言 lr-tb | tb-rl 的书写方式都有。

writing-mode这个CSS属性以前是IE的独有属性,IE5.5浏览器就已经支持了。在很长一段时间里,FireFox, Chrome这些现代浏览器都不支持writing-mode,各大现代浏览器纷纷对writing-mode实现了更加标准的支持(主要得益于FireFox浏览器的积极跟进)。

css writing-mode属性 示例

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

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<style>

table, td, th {

    border: 1px solid black;

}

table {

    border-collapse: collapse;

    width: 100%;

}

.example.Text1 span, .example.Text1 {

  writing-mode: horizontal-tb;

  -webkit-writing-mode: horizontal-tb;

  -ms-writing-mode: horizontal-tb;

}

.example.Text2 span, .example.Text2 {

  writing-mode: vertical-lr;

  -webkit-writing-mode: vertical-lr;

  -ms-writing-mode: vertical-lr;

}

.example.Text3 span, .example.Text3 {

  writing-mode: vertical-rl;

  -webkit-writing-mode: vertical-rl;

  -ms-writing-mode: vertical-rl;

}

.example.Text4 span, .example.Text4 {

  writing-mode: sideways-lr;

  -webkit-writing-mode: sideways-lr;

  -ms-writing-mode: sideways-lr;

}

.example.Text5 span, .example.Text5 {

  writing-mode: sideways-rl;

  -webkit-writing-mode: sideways-rl;

  -ms-writing-mode: sideways-rl;

}

</style>

</head>

<body>

<table>

    <tr>

        <th>value</th>

        <th>Vertical script</th>

        <th>Horizontal script</th>

        <th>Mixed script</th>

    </tr>

    <tr>

        <td>horizontal-tb</td>

        <td class="example Text1"><span>我家没有电脑。</span></td>

        <td class="example Text1"><span>Example text</span></td>

        <td class="example Text1"><span>1994年に至っては</span></td>

    </tr>

    <tr>

        <td>vertical-lr</td>

        <td class="example Text2"><span>我家没有电脑。</span></td>

        <td class="example Text2"><span>Example text</span></td>

        <td class="example Text2"><span>1994年に至っては</span></td>

    </tr>

    <tr>

        <td>vertical-rl</td>

        <td class="example Text3"><span>我家没有电脑。</span></td>

        <td class="example Text3"><span>Example text</span></td>

        <td class="example Text3"><span>1994年に至っては</span></td>

    </tr>

    <tr>

        <td>sideways-lr</td>

        <td class="example Text4"><span>我家没有电脑。</span></td>

        <td class="example Text4"><span>Example text</span></td>

        <td class="example Text4"><span>1994年に至っては</span></td>

    </tr>

    <tr>

        <td>sideways-rl</td>

        <td class="example Text5"><span>我家没有电脑。</span></td>

        <td class="example Text5"><span>Example text</span></td>

        <td class="example Text5"><span>1994年に至っては</span></td>

    </tr>

</table>

</body>

</html>

效果图:

1559037338301939.jpg

以上就是css writing-mode属性怎么用的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

css如何写二级下拉菜单

input实现文字超出省略号(代码示例)

css怎么实现字体描边效果

css中的角度单位有哪些?

css字体如何设置

css怎么设置文本框宽度

css怎么让盒子并排显示

css中display:hidden和display:none有什么区别

css怎么让字体变细

css如何实现n宫格布局

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




打赏

取消

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

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

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

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

评论

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