`

Flex之 justify-content 和 flex-direction 的应用

    博客分类:
  • css
阅读更多


flex 简介:

采用Flex布局的元素,被称为Flex容器(flex container),简称"容器"。其所有子元素自动成为容器成员,成为Flex项目(Flex item),简称"项目"


Flex-direction调整主轴方向(默认为水平方向)
包括row、column、row-reverse、column-reverse


https://www.cnblogs.com/wangyawei/p/9103573.html




要点1:
justify-content: space-between;
使元素各分部两端。

要点2:
flex-direction: row | column;
使元素 横向 或 纵向 排列






<!doctype html>
<html>
<head>

    <style>
    
        body {
            padding:50px 200px;
        }
    
        .item {
            width: 300px;
            padding: 10px 20px;
            background: #f5f6f8;
        }
        
        .title-node {
            display: -webkit-flex;
            display: flex;
            -webkit-flex-direction: row;
            flex-direction: row;
            -webkit-justify-content: space-between;
            justify-content: space-between;
        }

        .title-left {
            display: -webkit-flex;
            display: flex;
            -webkit-flex-direction: column;
            flex-direction: column;
        }

        .title-right {
            display: -webkit-flex;
            display: flex;
            -webkit-flex-direction: row;
            flex-direction: row;
        }
        
        .t-txt {
            color: #39a;
            font-weight: bold;
        }
        .t-sub{
            color: #888;
        }
        .icon{
            line-height: 36px;
        }
    
    
    </style>

</head>
<body>

    <div class="title-node item">

        <div class="title-left">
            <div class="t-txt">
                This is a list item title
            </div>
            <div class="t-sub">
                item(0)
            </div>
        </div>
        
        <div class="title-right">
            <span class="icon">icon</span>
        </div>

    </div>


<body>
</html>
































--
分享到:
评论

相关推荐

    动画演示flex属性 - 可点击切换属性

    动画演示flex布局,包括flex父容器属性以及flex布局子元素属性 flex父容器属性有: 一. flex-direction 主轴方向 row:从左到右 row-reverse... justify-content 子盒子主轴方向上的对齐方式 等,字数不够,无法一一列举

    Flex.less:一套用于CSS3 Flex布局的Less mixins

    justify-content align-items align-self align-content order flex flex-grow flex-shrink flex-basis flex-direction flex-wrap flex-flow 浏览器兼容性 在Firefox &lt;22中,您需要将以下代码段添加...

    Flex 布局教程:语法篇1

    3.1 flex-direction属性 3.4 justify-content属性 3.6 align-content属性

    Vue自定义日期输入框组件.zip

    justify-content: space-between;让两端靠边对齐 2、下拉选择按钮用css画一个向下的三角形 3、显示部分的下方放置一个div,上级div样式为display:flex;flex-direction: column;使其能够纵向排列,该div样式设为...

    js的带模糊效果交互式3D相册切换特效.zip

     justify-content: center;  align-items: center;  height: 100vh;  margin: 0; } .container {  display: flex;  flex-direction: row;  transition: all .5s ease;  perspective: 200px;  ...

    (微信小程序毕业设计)电器租赁小程序

    justify-content: center; padding-top: 20rpx; background: #fff; } .nav-item { margin: 30rpx 50rpx 10rpx; width: 80rpx; } .nav-item image { width: 100rpx; height: 100rpx; border-radius: 50%; }...

    移动端开发

    关于移动端开发的一些代码 display:flex;flex-direction 设置主轴方向,确定弹性子元素排列方式 ...justify-content 主轴上的对齐方式 align-items 侧轴上的对齐方式 align-content 侧轴上有空白时,侧轴的对齐方式

    从0到1,带你尝鲜flex布局

    文章目录1.flex布局体验1.1传统布局与flex布局2.flex布局原理2.1布局原理总结Flex布局原理3.flex布局父项常见属性3.1 常见父项属性3.2 flex-direction设置主轴方向3.3.justify-content 设置主轴上的子元素排列方式...

    flex弹性布局用法笔记

    flex介绍1.flex-direction:row|row-reverse|column|column-reverse|initial|inherit (盒子排列方向)2.flex-wrap: nowrap|wrap|wrap-reverse(拆行或拆列)附加:flex-flow(1,2的结合写法)3.justify-content: flex-...

    微信小程序控件学习:view的flex布局《下》

    (3)justify-content 设置子元素在横轴即X轴的排列位置 (4)align-items 设置子元素在Y轴的排列位置 (5)align-content 设置子元素在多个主轴线上排列的位置。 下面我们来讲讲 flex-item的属性,在flex容器中,每个子...

    react-profile

    工作正在进行中悬停效果export const ProjectsContainer = styled.div` font-family: 'Encode Sans', sans-serif; color: #070308; margin-bottom:8rem;... justify-content:flex-start; align-items:ce

    scss-masterclass:(S)CSS布局大师类:Flexbox&Grid

    justify-content : space-around; /* Cross Axis */ align-items : center; } flex-direction:降低主轴(默认为“行”) 调整内容:更改主轴的项目位置(flex-start,center,stretch等) align-items:更改...

    H5 C3粘稠状液体数字时钟动画代码.zip

    代码片段: html, body { margin: 0; padding: 0; height: 100%; } .wrap { ... display: flex;...flex-direction: column;... justify-content: center;   align-items: center; }

    微信小程序 (八)View组件详细介绍

    justify-content 主轴的对齐方式(如果flex-direction为row则主轴就是水平方向) 可选属性 (‘flex-start’, ‘flex-end’, ‘center’, ‘space-between’, ‘space-around’) align-items 侧轴对齐方式如果flex-...

    小程序常用的知识点

    justify-content: center; align-items: center; input           type="number" confirm-type="done" value="{{car_price}}" placeholder-style="color:#FF6000;margin-right:10rpx;font-size:28rpx;" ...

    最新CSS3学习视频教程 33讲完整版 后盾网CSS3视频教程

    ├01 css3元素选择器 属性选择器 伪类选择...├26 justify-content align-items align-content order.mp4 ├27 阿里矢量图标库的使用方法.mp4 ├28 淘宝网移动端首页开发实战1.mp4 └29 淘宝网移动端首页开发实战2.mp4

    js实现倒计时器自定义时间和暂停

    js倒计时器可自定义时间和暂停,效果如下,点击start 开始计时,end结束计时 分别复制 H5 css js 代码即可实现,具体...justify-content:center; align-items:center; } .tc-input-style{ outline:none;border:none;wi

    JS+Canvas实现五子棋游戏

    本文实例为大家分享了JS+Canvas实现五子棋游戏的具体代码,供大家参考,具体内容如下 布局+样式部分代码 : &lt;style type='text/css'&gt; canvas { display: block;... justify-content: center; } .btn-

    css使用flexbox布局容器内多元素水平居中

    想要实现这样一个父元素中的子元素都是居中的 ...复制代码代码如下:{justify-content:space-around;} 这样剩余的空间会自动分配到各元素周边:) 刚开始觉得没什么必要用sass,现在发现很多css代码还是复用性很高的

    前端大厂面试思维导图-css面试

    前端大厂面试题目思维导图,非常全面,包含了常见的面试题目,0.5px的线如何实现,sass的常用功能,弹性布局flex-direction,justify-content,align-items,css常见单位rpx、px、em、rem、%、vh、vw的区别,垂直...

Global site tag (gtag.js) - Google Analytics