首页 > 编程开发 > CSS    日期:2021-12-10 / 来自互联网 / 浏览

css怎么把一张图片放在底部

在css中,可以利用position属性,将图片元素设置为固定定位样式,然后通过bottom属性,设置图片元素距离底部的距离为0,就可以把图片固定在底部了。

当position属性的值为fixed时,会将元素设置为固定定位样式。

示例如下:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
  img{
    position:fixed;
    bottom:0;
  }
  </style>
</head>
<body>
  <img src="1118.02.png" alt="">
</body>
</html>

输出结果:

css怎么把一张图片放在底部

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章

1 2 3 4 5