简体   繁体   English

当包含margin-left和margin-right时,图像未显示在给定位置

[英]images are not shown at given positions when included margin-left and margin-right

I'm showing some images on the chart. 我在图表上显示了一些图像。 They are showing fine but issue is when included the margin-left and margin-right to give some space to show the chart. 它们显示的很好,但问题是当包含margin-left margin-right margin-left出一些空间来显示图表。

included css code: 包含的CSS代码:

#chart1 {
        margin: 0 auto;
        overflow : hidden;
        margin-left: 60px;
        margin-right: 60px;
    }

js code: Below js code is used to show the images at a particular location on the chart. js代码:以下js代码用于在图表上的特定位置显示图像。 The below code works when the chart is occupied to 100% , but when included the above css code, the image positions are not shown at given timeframes.. 下面的代码在图表占据100%时起作用,但是当包含上面的CSS代码时,在给定的时间范围内不会显示图像位置。

overlay.style.left = (overlayBounds.x / (timelineWidth / 100) ) + '%';

尝试overlay.style.left = ( overlayBounds.x / timelineWidth ) * 100 + '%';

#timeline {
  position: relative;
}

Then you will need to update 然后您将需要更新

.overlay {
  ...
  margin-top: -10px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM