私のウーコムウェブサイトでは、各製品に600px x 600pxのサムネイルがあります。このサムネイル内の画像は通常、水彩画(例:2000 x 2000)よりもはるかに大きくなります。私がしようとしているのは、画像を600x600以内に収め、白い枠線で負のスペースを埋めることです。指定された寸法内で画像を切り抜く方法
例(この600×600の画像の周りに白い背景の多くがあります) -
私はCSSでこれを行うことを試みたが、それは常に私のウェブサイトの残りの部分をアップmucks。これを達成するためのオンラインツールはありますか、または私は自分の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>