如何将一个图像放在另一个图像之上?

勒克斯

我已经看到一些解释如何使用绝对位置做到这一点的方法。我目前正在建立Bootstrap 3网站,因此无法使用absolute属性。

以下是我所讨论内容的快速模型(请注意,播放按钮不会被烧入下面的图像中)

小样

另外,如果您可以解释如何制作类似的渐变,那将是很好的。

我尝试使用z-index属性,但是使用它时,我不知道如何相对于具有较低z-indexes的元素定位元素。

Edit: The play-button (seen on top of the images) will not be a part of the jpg image asset. Rather, it will be its own svg asset put on top of the jpg (thumbnail) image. I choose this way so that I can animate the "play-button" independently.

Neither will the gradient, title, subtitle or "article-tag" be a part of the thumbnail image asset.

The red "divider's" will be its own svg asset as well.

Ideally, I would like to be able to place <img></img> objects on top of another <img></img> bounding box and be able to move it relative to the bounding box. eg x=50% y=50% for centering. The method should be scalable so that I can have more than two layers as well as having multiple objects on the same layer.

注意:缩略图将以1920x1080的分辨率存储在Web服务器上。当尝试使用“分隔线”作为背景图像时,我遇到了裁剪问题:

在此处输入图片说明

它不会扩大其父级<div>(另外,是否有一种方法可以检测用户的屏幕尺寸并相应地(在服务器上)重新缩放图片以提高加载速度?例如cookie或其他东西?)

我很抱歉可能违反了网站上的大量规则,这是我的第一个问题。

奥龙·本·戴维(Oron Ben-David)

关于渐变,简短的CSS文字将是:

background: -webkit-linear-gradient(135deg, #a11633 45%, #7D1229 48%, #7D1229 20%);

另外:我为布局创建了一个JSFiddle:)

HTML:

<div class="relative-container">
  <div class="absolute-container">
    <div class="flex-1">
    Img 1
    </div>
    <div class="flex-1">
    Img 2
    </div>
    <div class="flex-1">
    Img 3
    </div>
  </div>
</div>

CSS:

.relative-container{
  width:300px;
  height:200px;
  background: -webkit-linear-gradient(135deg, #a11633 45%, #7D1229 48%, #7D1229 20%);
}

.absolute-container{
  width:300px;
  height:100px;
  display:flex;
  align-items: center;
  position:absolute;
  top:55px;
}

.flex-1{
  flex:1;
  border:1px dashed black;
  text-align:center;
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何将一个图像浮动在另一个图像之上?

如何将图像放在另一个

在Windows 10中使用linux子系统时,如何将一个图像放在另一个图像之上?

如何将图像放置在另一个图像之上

如何使用iMagick将图像叠加在另一个图像之上

PyQt5:如何将 QPixmap 放在另一个 QPixmap 之上?

如何在HTML中将一个图像放置在另一个图像之上?

将图像放在另一个

将div放在另一个之上

将布局放在另一个之上

如何使用部分将背景图像放在另一个图像下方?

Html:如何将两个图像一个在另一个上面与文本放在同一行?

如何将一个DialogFragment提升到另一个之上?

使用 Bootstrap 4 将图像居中放置在另一个图像之上

如何使用CSS在另一个图像之上显示图像(透明)

我如何将条形图放在 r 中的另一个图形之上

当两个div都使用自动边距居中时,如何将一个div放在另一个之上?

如何将一个图像居中放置在另一个图像上

OpenCV Python:如何将一个图像叠加到另一个图像的中心

如何将图像拖到另一个图像背景上

如何将图像放置在android中的另一个图像上

如何将图像写到另一个图像上?

如何将每个选定的图像src替换为另一个图像

移动时如何将图像保留在另一个图像后面?

黑色时如何将BGR图像设置为另一个图像?

如何将图像的颜色转移到另一个图像?

如何将图像放入另一个图像视图

如何将图像放置在另一个具有透明背景的图像后面

如何将图像从图像选择器传递到另一个视图