九宫格flex布局案例

之前写垂直方向都是写死,今天看了flex布局,原来,垂直方向也是可以像水平方向一样。
 
  
html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <style>
        .lottery-draw-container{
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            width: 300px;
            height: 300px;
            border: 1px solid #000;
            display: flex;
            flex-direction: column;
        }
        .item{
            flex-basis: 100px;
            display: flex;
            justify-content:center;
            align-items: center;
            border: 1px solid #000;
        }
        .active{
            background-color: red;
        }
    style>
head>
<body>
<div class="lottery-draw-container">
    <div style="display: flex;flex:1;">
        <div class="item active"><span>一等奖span>div>
        <div class="item"><span>二等奖span>div>
        <div class="item"><span>三等奖span>div>
    div>
    <div style="display: flex;flex:1;">
        <div class="item"><span>四等奖span>div>
        <span class="item"><span>开始span>span>
        <div class="item"><span>五等奖span>div>
    div>
    <div style="display: flex;flex:1;">
        <div class="item"><span>六等奖span>div>
        <div class="item"><span>七等奖span>div>
        <div class="item"><span>八等奖span>div>
    div>
div>
body>
html>

你可能感兴趣的:(九宫格flex布局案例)