css中flex-direction属性的使用方法

发布时间:2020-09-24 11:12:16 作者:小新
来源:亿速云 阅读:194

这篇文章主要介绍css中flex-direction属性的使用方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

css flex-direction属性用于规定灵活项目的方向,如果元素不是弹性盒对象的元素,则flex-direction属性不起作用。

css flex-direction属性怎么用?

定义和用法

flex-direction 属性规定灵活项目的方向。

注意:如果元素不是弹性盒对象的元素,则 flex-direction 属性不起作用。

默认值: row

继承: 否

可动画化: 否。

版本: CSS3

JavaScript 语法:

object.style.flexDirection="column-reverse"

CSS 语法

flex-direction: row|row-reverse|column|column-reverse|initial|inherit;

属性值

row 默认值。灵活的项目将水平显示,正如一个行一样。

row-reverse 与 row 相同,但是以相反的顺序。

column 灵活的项目将垂直显示,正如一个列一样。

column-reverse 与 column 相同,但是以相反的顺序。

initial 设置该属性为它的默认值。

inherit 从父元素继承该属性。

实例

设置 <div> 元素内弹性盒元素的方向为相反的顺序:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#main {
    width: 400px;
    height: 400px;
    border: 1px solid #c3c3c3;
    display: -webkit-flex; /* Safari */
    -webkit-flex-direction: row-reverse; /* Safari 6.1+ */
    display: flex;
    flex-direction: row-reverse;
}

#main div {
    width: 50px;
    height: 50px;
}
</style>
</head>
<body>

<div id="main">
  <div style="background-color:coral;">A</div>
  <div style="background-color:lightblue;">B</div>
  <div style="background-color:khaki;">C</div>
  <div style="background-color:pink;">D</div>
  <div style="background-color:lightgrey;">E</div>
  <div style="background-color:lightgreen;">F</div>

运行结果:

css中flex-direction属性的使用方法

以上是css中flex-direction属性的使用方法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. css中top属性的使用方法
  2. css中width属性的使用方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css lex

上一篇:如何写网络爬虫程序

下一篇:网络爬虫的原理是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》