html中img tagDisplayimageCenter method currently I know three methods. The editor will share them to the Script House platform below. Friends who need them can refer to the method of displaying the center of the image in the img tag in the
. Currently, I know three methods. I will record them here.
The first one: using cssclip:rect(toprightbottomleft); Usage needs to be used withposition: absolute: as follows
##
##- Second: Use img’sbackground#. ##Attributes:
Use the background to control the center position of the image display. You need to set the background to scale according to the true width and height of the image. Then offset the movement amount of the background to control the width and height of the picture. What needs to be noted is that the src of the picture cannot be set. When the img tag does not set src, a gray border will appear on the displayed picture, and there is no way to remove it. b
ord
overflow: hidden; to control it, it is more flexible to use,
above
Comments
The above is the detailed content of Three methods in HTML to implement the img tag to only display the sample code in the center of the picture. For more information, please follow other related articles on the PHP Chinese website!