使用 CSS 实现背景图像的响应性
你可以尝试运行以下代码,以使用 CSS 实现背景图像的响应性 −
示例
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content="width = device-width, initial-scale = 1.0">
<style>
div {
width: 100%;
height: 300px;
border: 2px dashed blue;
background-image: url('https://tutorialspoint.com/python/images/python-data-science.jpg');
background-repeat: no-repeat;
background-size: contain;
}
</style>
</head>
<body>
<p>To check the effect, you need to resize the browser.</p>
<div></div>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP