css justify-content属性怎么用


当前第2页 返回上一页

css justify-content属性 示例

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

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<style>

.flex-container {

  padding: 0;

  margin: 0;

  list-style: none;

  display: flex;

}

.flex-start {

  justify-content: flex-start;

}

.flex-end {

  justify-content: flex-end;

.flex-end li {

  background: gold;

}

.center {

  justify-content: center;

.center li {

  background: deepskyblue;

}

.space-between {

  justify-content: space-between;

.space-between li {

  background: lightgreen;

}

.space-around {

  justify-content: space-around;

}

.space-around li {

  background: hotpink;

}

.space-evenly {

  justify-content: space-evenly;

}

.space-evenly li {

  background: #bada55;

}

.flex-item {

  background: tomato;

  padding: 5px;

  width: 60px;

  height: 50px;

  margin: 5px;

  line-height: 50px;

  color: white;

  font-weight: bold;

  font-size: 2em;

  text-align: center;

}

</style>

</head>

<body>

<ul class="flex-container flex-start">

  <li class="flex-item">1</li>

  <li class="flex-item">2</li>

  <li class="flex-item">3</li>

  <li class="flex-item">4</li>

  <li class="flex-item">5</li>

</ul>

<ul class="flex-container flex-end">

  <li class="flex-item">1</li>

  <li class="flex-item">2</li>

  <li class="flex-item">3</li>

  <li class="flex-item">4</li>

  <li class="flex-item">5</li>

</ul>

<ul class="flex-container center">

  <li class="flex-item">1</li>

  <li class="flex-item">2</li>

  <li class="flex-item">3</li>

  <li class="flex-item">4</li>

  <li class="flex-item">5</li>

</ul>

<ul class="flex-container space-between">

  <li class="flex-item">1</li>

  <li class="flex-item">2</li>

  <li class="flex-item">3</li>

  <li class="flex-item">4</li>

  <li class="flex-item">5</li>

</ul>

<ul class="flex-container space-around">

  <li class="flex-item">1</li>

  <li class="flex-item">2</li>

  <li class="flex-item">3</li>

  <li class="flex-item">4</li>

  <li class="flex-item">5</li>

</ul>

<ul class="flex-container space-evenly">

  <li class="flex-item">1</li>

  <li class="flex-item">2</li>

  <li class="flex-item">3</li>

  <li class="flex-item">4</li>

  <li class="flex-item">5</li>

</ul>

</body>

</html>

效果图:

2.jpg

说明:

红色列表是justify-content属性设置为 flex-start

黄色是justify-content属性设置为 flex-end

蓝色是justify-content属性设置为 center

绿色是justify-content属性设置为 space-between

粉红色是justify-content属性设置为 space-around

浅绿色是justify-content属性设置为 space-evenly

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

返回前面的内容

相关阅读 >>

css class和id选择器的区别是什么

css中不属于添加在当前页面的形式是什么

css怎么设置内边距

css有超文本标记选择器吗

css怎么设置右对齐

css如何设置斜体

css如何设置table边框的颜色

css如何禁止选中页面内容

如何利用纯css实现图片轮播

如何下载css里的图片

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




打赏

取消

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

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

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

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

评论

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