How to set image position in css

醉折花枝作酒筹
Release: 2023-01-05 16:10:00
Original
10739 people have browsed it

Method: First use the position attribute to specify the positioning type of the element, the syntax is "position:static|relative|fixed|absolute"; then use the top, bottom, left and right attributes to define the offset position of the picture element. accurate locating.

How to set image position in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

The position attribute specifies the positioning type of the element. This attribute defines the positioning mechanism used to establish the layout of the element. Any element can be positioned, but absolute or fixed elements generate a block-level box, regardless of the type of the element itself. A relatively positioned element is offset from its default position in normal flow.

Elements are actually positioned using the top, bottom, left and right attributes. However, these properties will have no effect unless the position property is set first. They work differently depending on the position value.

How to set image position in css

Example:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<style type="text/css">
			img {
				position: absolute;
				left: 100px;
				top: 100px
			}
		</style>
	</head>

	<body>
		<img  src="2.jpg" / alt="How to set image position in css" >
		
	</body>

</html>
Copy after login

Recommended learning: css video tutorial

The above is the detailed content of How to set image position in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!