青青青轩 2021-10-10 00:03 采纳率: 50%
浏览 35
已结题

怎样用HTML和css写成图示

img


初学,搞了很久也没让1和4,6和9挨着。

  • 写回答

1条回答 默认 最新

  • 关注

    可以用伸缩盒 Flex来做
    你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title> 页面名称 </title>
    <style type="text/css">
    .box {
        display: flex;
        flex-flow: column nowrap;
        width: 300px;
        height: 300px;
        border: 3px solid #f00;
    }
    .box > div {
        display: flex;
        flex-flow: row nowrap;
        justify-content: space-between;
    }
    .box > div:nth-child(2) {
        flex-grow: 1;
        align-items: center;
    }
    .box > div:nth-child(2) > div:nth-child(1) {
        align-self: flex-start;
    }
    .box > div:nth-child(2) > div:nth-child(3) {
        align-self: flex-end;
    }
    .box > div > div {
        width: 70px;
        height: 70px;
        background-color: #f99;
    }
    </style>
    </head>
    <body>
    
    <div class="box">
        <div>
            <div>1</div>
            <div>2</div>
            <div>3</div>
        </div>
        <div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
        </div>
        <div>
            <div>7</div>
            <div>8</div>
            <div>9</div>
        </div>
    </div>
    </body>
    </html>
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月19日
  • 已采纳回答 10月11日
  • 创建了问题 10月10日