2023.08.09 | admin | 159次围观
第一种:使用background-size:cover;
background-size属性指定背景图片大小html自适应浏览器大小。
注意浏览器兼容。
DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>背景图片自适应填充整个页面title>
head>
<style>
body{background: url(u=3577773561,2706257243&fm=26&gp=0.jpg) no-repeat;background-size:cover;}
style>
<body>
body>
html>
=============================================================================
第二种:background-size:100% 100%;background-attachment:fixed;
background-size属性指定背景图片大小。
background-attachment设置背景图像是否固定或者随着页面的其余部分滚动。
注意浏览器兼容html自适应浏览器大小。
DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>背景图片自适应填充整个页面title>
head>
<style>
body{background: url(u=3577773561,2706257243&fm=26&gp=0.jpg) no-repeat;background-size:100% 100%;background-attachment:fixed;}
style>
<body>
body>
html>
版权声明
本文仅代表作者观点。
本文系作者授权发表,未经许可,不得转载。
发表评论