Equation of img by size of header
-
Hello, I'm putting my head hat back. An image inside the header block, how can you level img by the size of the header block?
-
I understand your structure is as follows:
<header> <img src="src/images/header.jpg"> </header>
First, it's not always true. If the picture is visually background, it must be background, i.e., it shall be shown through the background.
background-image: url("src/images/header.jpg");
♪ In such a case, the picture shall be taken up with the help ofbackground-size
♪ In absolute/responsive units of measurement or special values such ascontain
(write on the larger side, not cut the picture, but on top/down or right/star will be empty) andcover
(write at least, cut the picture). It's quite easy to quantify this picture:background-position: center
(no or top/bottom/left/right).However, if you still want to your structure, then the hijacking is done with help.
width
andheight
Which we're askingimg
♪ In order to write a picture of the width, while keeping the proportions, we just write:header > img { width: 100%; height: auto; }
Of course, the proportions may not be maintained, and the images of the size of the block may be forced to spread, but in that case,
header
must be clearly prescribedwidth
andheight
♪