我正在尝试使用 CSS 网格构建网站的一部分。我试图让列表和图片保持在同一行中,并在屏幕大小改变时按比例缩小/增长。代码粘贴在下面。非常感谢任何帮助。
我想知道错误是否出在我的网格模板内。
.pm { display: inline-grid; max-width: 100%; position: relative; margin: auto; grid-template-areas: "title title" "list picture" "options options" "paragraph paragraph"; grid-template-rows: 10% 1fr 20% 10%; grid-template-columns: 1fr 1fr; align-items: center; } .pm h2 { grid-area: title; text-align: center; } .pm .container ul { grid-area: list; } .pm .container img { grid-area: picture; max-width: 30%; border-radius: 0.25em; } .pm .options { grid-area: options; } .pm .paragraph { grid-area: paragraph; }
<div class="pm section"> <h2>Preventative Maintenance:</h2> <div class="container"> <ul> <li>Calibration of each piece of equipment as required.</li> <li>Inspect any switches, controls and/or electrical components.</li> <li>Inspect motor brushes and clean the motor fan vents.</li> <li>Inspect and tighten hardware.</li> <li>Inspect all belts cables and chains.</li> <li>Lube all moving components as required.</li> </ul> <img src="./style/images/circuit.avif"> </div> <div class="options"> <h3>Options:</h3> <ul> <li>Monthly</li> <li>Quarterly</li> <li>Semi-annual</li> <li>Annual</li> </ul> </div> <div class="paragraph"> <p>Any findings will be reported in the invoice, with an option to have any findings quoted for repair, separately.</p> <p>Any parts needed, per the repair quote, would be ordered and all repairs would be scheduled following arrival of the parts.</p> </div> </div>
图像不在图片部分中,因为它嵌套在容器内,并且 img 标签本身不是网格项。
在工作代码下方