【发布时间】:2020-07-15 11:16:43
【问题描述】:
我有以下选项卡面板,我想将 svg 元素水平居中。我的 css 适用于第一个 svg 元素(柱形图),但不适用于第三个元素(圆环图)。两者都位于 tab-content 父级内的 div 内,但只有一个正在获取 css 修饰符。如何在它的父 svg 中居中圆环图? Here 是我正在研究的代码。
CSS:
.tab-content {
display: flex;
justify-content: center;
}
HTML:
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade show active" id="tab1">
<h3>Column Chart <small>Lorem ipsum</small></h3>
<svg id="chart1" width="900" height="400"></svg>
</div>
<div role="tabpanel" class="tab-pane fade" id="tab2">
<h3>Treemap <small>Lorem ipsum</small></h3>
<svg id="chart2" width="900" height="400"></svg>
</div>
<div role="tabpanel" class="tab-pane fade" id="tab3">
<h3>Donut Chart <small>Lorem ipsum</small></h3>
<svg id="chart3" width="900" height="400"></svg>
</div>
<div role="tabpanel" class="tab-pane fade" id="tab4">
<h3>Time Series <small>Lorem ipsum</small></h3>
<svg id="chart4" width="900" height="400"></svg>
</div>
</div>
【问题讨论】:
标签: javascript html css d3.js