CSS

CSSで画像を領域内に収める

'19.02.02
.outer {
position: relative;
width:320px;
height:180px;
margin:1em 0;
border:1px solid #ccc;
background-color:#eee;
}
.inner {
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
width:auto;
height:auto;
max-width:100%;
max-height:100%;
margin:auto;
}

(View134)