Pure CSS3 mind map style example

Pure CSS3 mind map style example

Mind Map

He probably looks like this:

Most of the implementations on the Internet are implemented using d3.js, and some are implemented manually using svg. Recently, my work requires it, and I am very lazy, so I am wondering if it can be implemented using CSS3?

The answer is yes. Here is the code

HTML code

<div class="mainBody" id="node1">
    <h1>node1</h1>
    <div class="oneBody">
        <div class="mainBody">
            <h1>node2</h1>
            <div class="oneBody">
                <div class="mainBody">
                    <h1>node3</h1>
                    <div class="oneBody">
                        <div class="mainBody">
                            <h1>node4</h1>
                        </div>
                        <div class="mainBody">
                            <h1>node4</h1>
                        </div>
                        <div class="mainBody">
                            <h1>node4</h1>
                        </div>
                    </div>
                </div>
                <div class="mainBody">
                    <h1>node3</h1>
                </div>
                <div class="mainBody">
                    <h1>node3</h1>
                </div>
            </div>
        </div>
        <div class="mainBody"><h1>node2</h1></div>
        <div class="mainBody"><h1>node2</h1></div>
    </div>
</div>

CSS3 code

.mainBody{
    display: -webkit-flex; /* Safari */
    display: flex;
    flex-direction: row;
    justify-content: flex-start ;
}
.sbody{

}
.oneBody{
    display: -webkit-flex; /* Safari */
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}
#node1{
    /*height: 200px;*/
    margin-top: 100px;
    margin-left: 100px;
}
h1{
    line-height: 100%;
    display: -webkit-flex; /* Safari */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

The actual effect is as shown below:

Oh, it's a bit crude... But you can do whatever you want with the style. To add nodes, you only need to add the corresponding node code in HTML. The height and position are adaptive. Thanks to CSS3 flex, you are lucky to live in this era.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  Detailed explanation of the process of building Prometheus+Grafana based on docker

>>:  IE6 distortion problem

Recommend

mysql5.6.8 source code installation process

Kernel: [root@opop ~]# cat /etc/centos-release Ce...

A brief discussion on the optimization of MySQL paging for billions of data

Table of contents background analyze Data simulat...

A brief introduction to React

Table of contents 1. CDN introduction 1.1 react (...

Detailed explanation of vue page state persistence

Table of contents Code: Replenish: Summarize Requ...

Let me teach you how to use font icons in CSS

First of all, what is a font icon? On the surface...

How MLSQL Stack makes stream debugging easier

Preface A classmate is investigating MLSQL Stack&...

Detailed explanation of Vue mixin

Table of contents Local Mixin Global Mixins Summa...

Vue folding display multi-line text component implementation code

Folding display multi-line text component Fold an...

IE6 BUG and fix is ​​a preventive strategy

Original article: Ultimate IE6 Cheatsheet: How To...

Detailed explanation of Truncate usage in MYSQL

This article guide: There are two ways to delete ...

Vue uses dynamic components to achieve TAB switching effect

Table of contents Problem Description What is Vue...

Native js to achieve simple carousel effect

This article shares the specific code of js to ac...

How to install ROS Noetic in Ubuntu 20.04

Disclaimer: Since the project requires the use of...

React Class component life cycle and execution order

1. Two ways to define react components 1. Functio...