Home > Article > Web Front-end > How to move images up with css
You can move the image upward through the CSS top attribute, which specifies the vertical offset of the image relative to the parent element. The steps are as follows: 1. Select the picture element; 2. Use the top attribute to specify the upward movement amount of the picture, the unit can be pixels, percentage, em or rem.
How to use CSS to move the image up
To move the image up, you can use CSStop
Properties. This property specifies the vertical offset of the element relative to its parent element.
Steps:
top
attribute to specify the amount by which the image moves upward. Sample code:
<code class="css">img { top: -20px; }</code>
This will move the image up by 20 pixels.
Note:
top
attribute is applied to a block-level element, it will be moved relative to the top of its parent element's padding box. For inline elements, it is moved relative to the baseline of its parent element. The above is the detailed content of How to move images up with css. For more information, please follow other related articles on the PHP Chinese website!