Ask Your Question
4

What is the method to ensure an image remains between two <br> tags regardless of the screen size?

asked 2022-05-19 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-04-13 21:00:00 +0000

bukephalos gravatar image

One method is to use CSS to set the image as a background of a div element, and then set the div element's height to a percentage of the viewport height using the "vh" unit. This will ensure the div and the background image will resize proportionally to the screen size. For example:

<div style="height: 50vh; background-image: url('image.jpg'); background-size: cover;"></div>

This code will create a div with a height of 50% of the viewport height, and set the background image to "image.jpg" with the "cover" value for the "background-size" property, which will ensure the image covers the entire div regardless of its size. The div can then be positioned between the "
" tags to ensure it remains there regardless of the screen size.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-19 11:00:00 +0000

Seen: 13 times

Last updated: Apr 13 '21