Let’s say I have an img element inside a div, how do I make the div have the same width and height of its content using CSS?
Let’s say I have an img element inside a div , how do I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Floating the div would make it shrinkwrap and so the div would only have room for the content inside.
You will probably need to use
clearon the elements coming afterwards.Another way would be to use
inline-block.