使用 CSS 浮动属性对齐元素


要使用 CSS 中的浮动属性对齐元素,你可以尝试运行以下代码 −

示例

在线演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .demo {
            float: right;
            width: 200px;
            border: 1px dashed blue;
            padding: 5px;
         }
      </style>
   </head>
   <body>
      <h1>Heading</h1>
      <div class = "demo">
         <p>This is demo text and right aligned.</p>
      </div>
   </body>
</html>

输出

更新时间:22-Jun-2020

132 查看次数

启动你的 职业生涯

完成课程以获得认证

开始学习
广告
© . All rights reserved.