2017-05-18 12 views
0

私が手にしている課題を記述する正しい言葉はほとんど見つかりません。私はノードを組織図のように配置しています。私は、ラインを介してこれらのノードを接続する方法があるかどうかを知りたいのですが、これらのラインは動的でなければなりません。CSSを使用してノード間に線を描く

enter image description here

物事はPICに示されているものと似ています。

ノードを接続する線を描くのに加えて、<ul><li>構造のようなノードを動的に生成するより効率的な方法があるかどうかを知ってうれしいです。続い

iが(ブートストラップの非常に最小限の使用を有する)画像上に生成するために使用したコードスニペットである:一言で言えば

<!DOCTYPE html> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html"; charset="utf-8" /> 
     <title>Oval</title> 
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
     <style type="text/css"> 
      body{ 
       padding-top: 20px; 
      } 

      .oval { 
       width: 400px; 
       height: 160px; 
       background: #5fa2dd; 
       border-radius: 50%; 
       text-align: center; 
      } 

      .circle { 
       width: 190px; 
       height: 190px; 
       background: #9cc96b; 
       border-radius: 50%; 
      } 

      .emptyrow{ 
       margin : 50px 0; 
      } 

      .med-circle{ 
       width: 150px; 
       height: 150px; 
       background: #9cc96b; 
       border-radius: 50%; 
      } 
     </style> 
    </head> 
    <body class="container"> 
     <div class="row"> 
      <div class="col-lg-4 col-lg-offset-4 oval"><p>key1 : value1</p><p>key2 : value2</p><p>key3 : value3</p></div> 
     </div> 
     <div class="row emptyrow"> 
     </div> 
     <div class="row"> 
      <div class="col-lg-2 col-lg-offset-2 circle"></div> 
      <div class="col-lg-2 col-lg-offset-2 circle"></div> 
      <div class="col-lg-2 col-lg-offset-2 circle"></div> 
     </div> 
    </body> 
</html> 

質問:動的ノードを生成する

  1. 良い方法
  2. これらのノードを結ぶ線を描くにはどうすればよいですか?
+0

スニペット

Fiddle demo

を処理するためにはるかに困難を持つことになります行が含ま

あなたが望むほとんど何でも行うことができますして

、 https://codepen.io/siiron/pen/aLkdE –

+0

このオプションもあります:ht tp://fperucic.github.io/treant-js/ –

答えて

1

私はSVGに行きます。 CSSは、スタックが

svg { 
 
    display: block; 
 
    margin: auto; 
 
    width: 100vmin; 
 
} 
 
.shadow { 
 
    -webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.5)); 
 
      filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.5)); 
 
} 
 
.line { 
 
    stroke: gray; 
 
} 
 
.ellipse { 
 
    fill: lightblue; 
 
} 
 
.circle { 
 
    fill: lightgreen; 
 
}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="395" height="305" viewBox="0 0 395 305" class="shadow"> 
 
    <line x1="195" y1="70" x2="50" y2="200" stroke-width="1" class="line"/> 
 
    <line x1="195" y1="70" x2="195" y2="200" stroke-width="1" class="line"/> 
 
    <line x1="195" y1="70" x2="340" y2="200" stroke-width="1" class="line"/> 
 
     
 
    <ellipse cx="195" cy="70" rx="120" ry="70" class="ellipse"/> 
 
    <text x="50%" y="70" text-anchor="middle" dy=".3em">Some text...</text> 
 
    
 
    <circle cx="50" cy="250" r="50" class="circle"/> 
 
    <text x="50" y="250" text-anchor="middle" dy=".3em">Some text...</text> 
 
    
 
    <circle cx="195" cy="250" r="50" class="circle"/> 
 
    <text x="195" y="250" text-anchor="middle" dy=".3em">Some text...</text> 
 

 
    <circle cx="340" cy="250" r="50" class="circle"/> 
 
    <text x="340" y="250" text-anchor="middle" dy=".3em">Some text...</text> 
 
</svg>

関連する問題