Home > Web Front-end > CSS Tutorial > Positioning HTML elements using CSS

Positioning HTML elements using CSS

WBOY
Release: 2023-09-09 21:01:02
forward
606 people have browsed it

使用 CSS 定位 HTML 元素

CSS helps you position HTML elements. You can place any HTML element anywhere you like. You can specify whether an element is positioned relative to its natural position on the page or absolutely positioned based on its parent element.

Example

Let’s look at an example of relative positioning -

 <html>
    <head>
    </head>
    <body>
       <div style = "position:relative;left:70px;top:1px;background-color:blue;color: white;">
          This div has relative positioning.
       </div>
    </body>
</html>
Copy after login

The above is the detailed content of Positioning HTML elements using CSS. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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