如何使用 CSS 将文本定位在图像的左下角


要将文本定位在左下角,可以使用 bottomleft属性。你可以尝试运行以下代码,将文本定位在图像的左下角

示例

动态演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .box {
            position: relative;
         }
         img {
            width: 100%;
            height: auto;
            opacity: 0.6;
         }
         .direction {
            position: absolute;
            bottom: 10px;
            left: 19px;
            font-size: 13px;
         }
      </style>
   </head>
   <body>
      <h1>Heading One</h1>
      <p>Below image has text in the bottom left:</p>
      <div class = "box">
         <img src = "https://tutorialspoint.com/python/images/python_data_science.jpg" alt="Tutorial" width="800" height="400">
         <div class = "direction">Bottom Left Corner</div>
      </div>
   </body>
</html>

更新时间:2020 年 6 月 24 日

1K+ 浏览量

启动你的 职业生涯

完成课程获得认证

开始
广告
© . All rights reserved.