【问题标题】:Another stacking centered images question另一个堆叠居中的图像问题
【发布时间】:2020-10-28 00:34:12
【问题描述】:

我有一个电视机的图像,我想在其中放置“节目”的图像,在屏幕上水平居中(在电视屏幕图像的前面)。我正在使用 a 来设置放置图像的区域的尺寸,但如果没有必要,我不必这样做。我已经摆弄了位置:和图像的绝对/相对,但我不能让两个图像都居中和堆叠 - 要么它们在居中时部分重叠,要么它们在“”的边缘完美对齐。这是代码的当前迭代。任何建议将不胜感激。

<div id="sourceDiv" align="center">
    <img class="test" src="uvaCover.jpg" style="z-index:2; width:800px">
    <img class="test" src = "tvScreen.jpg" style="z-index:1; width:900px">
</div>

.test {
    position: absolute;
    display: block;
    margin:auto;
    height:auto;
    overflow: hidden;
  }

#sourceDiv {
  position:relative;
  background-color: red;
  top:170px;
  left: 20px;
  width:1000px;
  height: 800px;
  margin:auto;
}

【问题讨论】:

    标签: image layer stacked


    【解决方案1】:

    我找到了答案。对于“:

      display: flex;
      align-items: center;
      justify-content: center;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多