html - 如何将背景图片放在两个 div 前面?
问题描述
我正在使用带有自定义组件的 Angular 框架。这是代码:
</form-line>
<form-line>
</form-line>
<form-line>
<div *formLineChild>
<img
src="cat.jpg">
</div>
</form-line>
<form-line>
</form-line>
我希望猫图像溢出两条白色表格线。这是它目前的样子:
解决方案
试试这个造型:
#formLineChild {
position: relative;
height: 70px;
background-color: gray;
margin-top: 2rem;
}
img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div id="formLineParent">
<div id="formLineChild">
<img src="https://source.unsplash.com/100x100/?cat">
</div>
</div>
推荐阅读
- wix - WIX - 如何将从注册表读取的文件位置传递给自定义操作?
- sapui5 - SAPUI5 应用程序中的 JQuery 日期滑块
- jquery - 隐藏除当前弹出窗口之外的所有弹出窗口?
- php - 从程序将数据保存或存储在数据库中
- flutter - Flutter ListWheelScrollView
- android - 从与 FileProvider 共享大 pdf 文件的电子邮件客户端返回后,onCreate 被调用
- html - div 被放在上面的 div 中
- jsp - 为什么会话在我的 JSP 页面中返回 null?
- powershell - CSV 为空以导出广告用户的自定义属性
- runtime-error - 打开 SAP 时出现“nwbc.exe 已停止工作”错误