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

Positioning HTML elements using CSS

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBforward
2023-09-09 21:01:02633browse

使用 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>

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete