写一个html 全局自适应背景图片代码httpimg9a18cn20230914a154bf7f2587fpng 这是图片
你可以使用CSS的background-size属性来实现全局自适应背景图片。以下是一个示例代码:
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('http://img.9a18.cn/2023/09/14/a154bf7f2587f.png');
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
}
</style>
</head>
<body>
<!-- 页面内容 -->
</body>
</html>
在上面的代码中,我们将背景图片设置为http://img.9a18.cn/2023/09/14/a154bf7f2587f.png,然后使用background-size: cover;来让背景图片自适应屏幕大小。background-repeat: no-repeat;用于禁止背景图片重复,background-position: center center;用于将背景图片居中显示。
你可以将上述代码复制到一个HTML文件中,并将http://img.9a18.cn/2023/09/14/a154bf7f2587f.png替换为你想要使用的图片链接。
原文地址: https://www.cveoy.top/t/topic/i8Pj 著作权归作者所有。请勿转载和采集!