How can I fit my image into a box? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

How can I fit my image into a box?

4th Sep 2016, 1:33 PM
smart
5 ответов
+ 1
It depends on the width and hight of the image and also of the box. it depends also if you want it to be responsive or not...try using width:x% and hight:y%...(with x and y numbers from 0 to 100) you can use also pixels (px)... Try also to use min-width and hight or max-width... If you want it in center, don't forget to write text-align: center;
4th Sep 2016, 9:59 PM
Antonio Panfili
+ 1
background:url(your image.jpg); background-size:div- width div- height; ex: div{ height:100px; width:100px; background:url(image.jpg); background-size:100px 100px; }
6th Sep 2016, 7:48 AM
Vijay Kumar
Vijay Kumar - avatar
0
you can also try: .yourTagReference { background-image: url ('yourBackgroundLocation'); background-size: contain; }
6th Sep 2016, 1:55 PM
Hardouin Nicolás
Hardouin Nicolás - avatar
0
max-width: 100%; width: 100%;
8th Sep 2016, 12:46 AM
Toni D'Angelo
Toni D'Angelo - avatar
0
thanks u all
8th Sep 2016, 7:48 PM
smart