LoginSignup
0
0

More than 1 year has passed since last update.

【CSS】画像の位置を調整する

Posted at

img画像の縦横比を維持したままトリミングする

exampl.html
<div>
  <img src="*******" class="img">
</div>
example.module.scss
div {
  width: 100px;
  height: 100px;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;  
    object-position: 0% -10%;  //数値は例えです 
  }
}

object-fit: cover
object-position: 横の位置 縦の位置 //

この2つを設定することで、画像の縦横比を維持したまま画像をトリミングできます。

こちらの記事が参考になりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0