2016-08-18 5 views
0

IはjQuery別のdivを基準にdivの位置を設定する方法は?

<div id="chart-2" class="graph"></div> 
<div id="chart2Buttons"></div> 

まずDIV私は第Iは、下の画像に表示するように、第1のdiv下に置くことになっていますボタンを表すhighchart.jsを使用してプロットしていたグラフを示し、HTML inmy 2つのdivの下有してい。 enter image description here

私はこれを達成して最初のdivの右下に2番目のdivを配置する方法を教えてください。

おかげ

答えて

1

は、CSSルールを追加します。

#chart2Buttons { 
    display: inline-block; 
    float: right; 
} 
+0

以下のように下の隅に置きありがとう!今働いている。 – Ruhul

1

はこのCSSを試してみてください:

​​
0

は、チャートやボタンにラッパーdiv要素を追加し、インラインブロックと位置に表示を設定しますラッパーの相対。絶対位置のボタンと

.graph{ 
 
    width: 400px; 
 
    height: 400px; 
 
    background: crimson; 
 
    line-height: 400px; 
 
    text-align: center; 
 
    color: white; 
 
    font-size: 20px; 
 
} 
 

 
.wrapper{ 
 
    position:relative; 
 
    display: inline-block; 
 
} 
 

 
#chart2Buttons{ 
 
    position: absolute; 
 
    width: 40px; 
 
    height: 40px; 
 
    right: 0; 
 
    bottom: 0; 
 
    background: cornflowerblue; 
 
    color: white; 
 
    line-height: 40px; 
 
    text-align: center; 
 
}
<div class="wrapper"> 
 
    <div id="chart-2" class="graph"> GRAPH </div> 
 
    <div id="chart2Buttons">B</div> 
 
</div>

関連する問題