HTML, CSS

CSS-사진 크기 조절

5_hyun 2022. 5. 9. 00:40
반응형

<div class="container1">
            <div class="row">
                <div class="col-md-4">
                    <div class="card" style="width: 100%;">
                        <img src="https://img.seoul.co.kr/img/upload/2015/07/17/SSI_20150717173042_V.jpg" class="card-img-top" alt="...">
                        <div class="card-body">
                            <h5 class="card-title">Card title</h5>
                            <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                            <a href="#" class="btn btn-primary">Go somewhere</a>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="card" style="width: 100%;">
                        <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTEfEkcmS4iktr-WhCOq_8QfD96mUB-01jnQA&usqp=CAU" class="card-img-top" alt="...">
                        <div class="card-body">
                            <h5 class="card-title">Card title</h5>
                            <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                            <a href="#" class="btn btn-primary">Go somewhere</a>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="card" style="width: 100%;">
                        <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR4IjJ78I527tazKwZwJQbVhnPhqfkB8SD8dA&usqp=CAU" class="card-img-top" alt="...">
                        <div class="card-body">
                            <h5 class="card-title">Card title</h5>
                            <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                            <a href="#" class="btn btn-primary">Go somewhere</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

이 코드에서 사진의 크기를 통일 시키려고 했다.

 

-CSS

img {
    width : 50%;
    height: 40vh;
}

이렇게 하여 가로와 세로를 맞춰줬다.

반응형