PHP前端开发

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

百变鹏仔 4周前 (09-20) #CSS
文章标签 放在
方法:1、利用position属性将图片元素设置为固定定位样式,语法为“图片元素{position:fixed;}”;2、利用bottom属性,将固定定位样式的图片元素固定在底部即可,语法为“图片元素{bottom:0;}”。

本教程操作环境:windows10系统、CSS3&&HTML5版、Dell G3电脑。

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>  @@##@@</body></html>

输出结果:

(学习视频分享:css视频教程)