+ 1

[html, css] there is some problem in my code

so, there is one div element and one img in one row, and I can't center align the text in div element(there is p element inside div) and I want to make a div element and img the same size, but I can't. And please don't say use padding, because I want to make it responsive. BTW, the div element is smaller than the img element

10th Jun 2020, 10:26 PM
jason jang
jason jang - avatar
5 odpowiedzi
+ 3
div{ height:200px; width:200px; background-color:blue; display:flex; align-items:center; justify-content:center; } </style> </head> <body> <div><p>hello</p></div>
10th Jun 2020, 10:48 PM
Abhay
Abhay - avatar
+ 2
By giving both same heights?
10th Jun 2020, 10:58 PM
Abhay
Abhay - avatar
+ 2
so you can also do same for height like 30% or whatever height for both?
10th Jun 2020, 11:02 PM
Abhay
Abhay - avatar
+ 1
thanks, but do you know how to make div element to have the same height as img?
10th Jun 2020, 10:57 PM
jason jang
jason jang - avatar
0
oh, I wanted to make it responsive, so I set the height as auto and width as 50%
10th Jun 2020, 11:00 PM
jason jang
jason jang - avatar