[英]how can I fix these margins (black bars) in my CSS stylesheet
I am building a d3.js javascript visualization based on an example found here and here .我正在根据此处和此处找到的示例构建 d3.js javascript 可视化。 It all works perfectly fine when I use a live server via Visual Studio Code, but once I upload it to my website, it just almost works... I am getting some strange black bars above and below the country flags in the hover information box.
当我通过 Visual Studio Code 使用实时服务器时,一切都很好,但是一旦我将它上传到我的网站,它几乎可以正常工作......我在悬停信息框中的国旗上方和下方出现了一些奇怪的黑条.
This is how it looks offline:这是它离线的样子:
This is how it looks online (with ugly black bars above and below the flag):这是它在网上的外观(旗帜上方和下方都有丑陋的黑条):
This is the code I used to create the boxes that pop up when hover over这是我用来创建悬停时弹出框的代码
<div class="card">
<img class="card-img" src="${flagEndpoint}/${flagName}.png" alt="flag" />
<div class="container">
<span class="card-title">${d.NAME}</span> <br />
<div class="card-spacer"></div>
<hr />
<div class="card-spacer"></div>
<span><b>Total Trade:</b> ${d.Total === -1 ? 'No Data available' : d3.format('.4s')(d.Total).replace(/G/,"B USD").replace(/M/,"M USD").replace(/k/,"k USD") } </span><br />
<span><b>Total Export:</b> ${d.Export === -1 ? 'No Data available' : d3.format('.4s')(d.Export).replace(/G/,"B USD").replace(/M/,"M USD").replace(/k/,"k USD") } </span> <br />
<span><b>Total Import:</b> ${d.Import === -1 ? 'No Data available' : d3.format('.4s')(d.Import).replace(/G/,"B USD").replace(/M/,"M USD").replace(/k/,"k USD") } </span>
<div class="card-spacer"></div>
<hr />
<div class="card-spacer"></div>
<span><b>Largest Export:</b> ${d.Export_trade_value_usd === -1 ? 'No Data available' : d.Export_commodity}</span><br />
<span><b>Value largest Export: </b>${d.Export_trade_value_usd === -1 ? 'No Data available' : d3.format('.4s')(d.Export_trade_value_usd).replace(/G/,"B USD").replace(/M/,"M USD").replace(/k/,"k USD") } </span><br /><br />
<span><b>Largest Import:</b> ${d.Import_trade_value_usd === -1 ? 'No Data available' : d.Import_commodity}</span><br />
<span><b>Value largest Import: </b>${d.Import_trade_value_usd === -1 ? 'No Data available' : d3.format('.4s')(d.Import_trade_value_usd).replace(/G/,"B USD").replace(/M/,"M USD").replace(/k/,"k USD") } </span>
</div>
</div>
and this is the custom css I added to my website.这是我添加到我的网站的自定义 css。
.card {
font-family: 'Space Mono', monospace;
transition: 0.3s;
background-color: black;
width: 320px;
border: 4px solid rgb(0, 107, 63) ;
border-radius: 10px;
z-index: 2;
padding: 0px;
margin-top:-10px;
margin-bottom:-5px;
}
.container {
padding-top: -10px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
text-align: left;
margin-top:-10px;
margin-bottom:-5px;}
.card-img {
object-fit: contain;
width: 100%;
border: 0;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
padding: -10px;
margin-top:-10px;
margin-bottom:-10px;
}
.card-title {
font-weight: bold;
margin: 1px;
padding: 1px;
margin-top:-10px;
margin-bottom:-10px;
}
.card-spacer {
height: 1px;
padding-top: 1px;
padding-bottom: 1px;
padding-left: 1px;
padding-right: 1px;
margin-top:-10px;
margin-bottom:-10px;
}
I have tried changing all paddings and margins and that does effect the other dimensions of the cards/container, but nothing seems to affect the bars below the country flags.我已尝试更改所有填充和边距,这确实会影响卡片/容器的其他尺寸,但似乎没有影响国旗下方的条形。 This probably means it takes some sore of default .css from my website (a hugo page hosted on netlifly), but I can simply not figure out what parameter.
这可能意味着它需要从我的网站(托管在 netlifly 上的一个 Hugo 页面)中获取一些默认的 .css,但我根本无法弄清楚是什么参数。
This is a live example https://ghanadatastuff.com/post/test_javascript/test_javascripts/这是一个活生生的例子https://ghanadatastuff.com/post/test_javascript/test_javascripts/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.