在我的woocommerce網站上,每個產品都有一個600px x 600px的縮略圖,縮略圖中的圖像通常比水彩畫更大(例如2000 x 2000)。我想要做的是將圖像放入600x600以內,並用白色邊框填充空白區域。如何在指定尺寸內裁剪圖像
我試圖用CSS來做到這一點,但它總是渣土了我的網站的其餘部分。有沒有可以實現這一目標的在線工具,還是應該繼續在我的CSS上工作?
CSS -
.woocommerce ul.products li.product, .woocommerce-page ul.products li.product {
height: 330px;
width: 330px;
position: relative;
}
.woocommerce ul.products li.product a img {
max-height: 90%;
max-width: 90%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
background: #3A6F9A;
border: 2px solid gray;
box-shadow: 10px 10px 5px #888888;
}
HTML -
<li class="post-267 product type-product status-publish has-post-thumbnail first instock shipping-taxable purchasable product-type-variable has-default-attributes has-children">
<a href="http://localhost/testsite/?product=autumn-by-the-lake-copy" class="woocommerce-LoopProduct-link"><img width="3150" height="2253" src="http://localhost/testsite/wp-content/uploads/2017/03/Autumn-by-the-Lake-Carolyn-Judge-Watercolours.jpg" class="attachment-shop_catalog size-shop_catalog wp-post-image" alt="Autumn by the Lake Carolyn Judge Watercolours" title="Autumn by the Lake Carolyn Judge Watercolours" srcset="http://localhost/testsite/wp-content/uploads/2017/03/Autumn-by-the-Lake-Carolyn-Judge-Watercolours.jpg 3150w, http://localhost/testsite/wp-content/uploads/2017/03/Autumn-by-the-Lake-Carolyn-Judge-Watercolours-300x215.jpg 300w, http://localhost/testsite/wp-content/uploads/2017/03/Autumn-by-the-Lake-Carolyn-Judge-Watercolours-768x549.jpg 768w, http://localhost/testsite/wp-content/uploads/2017/03/Autumn-by-the-Lake-Carolyn-Judge-Watercolours-1024x732.jpg 1024w" sizes="(max-width: 3150px) 100vw, 3150px" />
<h2 class="woocommerce-loop-product__title">Autumn By The Lake (Copy)</h2></a>
</li>