我试图把两个图像放在彼此的顶部,并使它们适当地对齐,形成一个房屋形状的物体.其中一个图像是正方形,另一个是三角形.三角形必须在顶部,正方形必须在底部.
这是HTML码:
<div class="heading">
<h2><span class="bold_text">RENT</span><span class="light_text">HOMES</span></h2>
<div class="house">
<img src="./img/house_top.svg" alt="house top">
<img src="./img/house_bottom.svg" alt="house bottom">
</div>
</div>
这是一段css代码: `.标题{ 显示:Flex; }
.heading .house {
display: grid;
height: 25px;
width: auto;
margin: 0;
padding: 0;
gap: 0;
}`
这就是我正在努力实现的目标: figma picture个
我使用"网格"将图像彼此对齐.我还将"填充"和"边距"设置为0.但两幅图像之间仍然有空间,它们并不是垂直对齐在一条直线上.这就是现在的情况. my code so far个
三角形SVG图片代码:
<svg width="33" height="24" viewBox="0 0 33 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <g filter="url(#filter0_d_174_86)"> <path d="M16.5 0L28.1913 15.75H4.80866L16.5 0Z" fill="#D9D9D9"/> <path d="M5.80251 15.25L16.5 0.838871L27.1975 15.25H5.80251Z" stroke="#475C46"/> </g> <defs> <filter id="filter0_d_174_86" x="0.808594" y="0" width="31.3828" height="23.75" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"> <feFlood flood-opacity="0" result="BackgroundImageFix"/> <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/> <feOffset dy="4"/> <feGaussianBlur stdDeviation="2"/> <feComposite in2="hardAlpha" operator="out"/> <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/> <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_174_86"/> <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_174_86" result="shape"/> </filter> </defs> </svg>
正方形SVG图像的代码:
<svg width="29" height="30" viewBox="0 0 29 30" fill="none" xmlns="http://www.w3.org/2000/svg"> <g filter="url(#filter0_d_174_87)"> <rect x="4" width="21" height="22" fill="#D9D9D9"/> <rect x="4.5" y="0.5" width="20" height="21" stroke="#475C46"/> </g> <defs> <filter id="filter0_d_174_87" x="0" y="0" width="29" height="30" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"> <feFlood flood-opacity="0" result="BackgroundImageFix"/> <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/> <feOffset dy="4"/> <feGaussianBlur stdDeviation="2"/> <feComposite in2="hardAlpha" operator="out"/> <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/> <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_174_87"/> <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_174_87" result="shape"/> </filter> </defs> </svg>