Let’s say you have a div wrapping an image. How would you style the div so that it creates a border of even width on all four sides of the image?
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.
If the
divdoesn’t have to be there, you might as well just give theimgan actual border and be done with it. Specifying one width value creates an equally-thick border around all sides.jsFiddle preview
Otherwise, if you need to use a
divas a border for whatever reason, make it an inline block, and make theimga block. Then either give thedivpadding or give theimgmargins.jsFiddle preview