html - 为什么我最小化屏幕时图像没有改变大小?
问题描述
为什么我把屏幕变小后图像没有改变大小?当我放大或缩小屏幕时,我想重新调整图像大小。这就是我尝试使用 VS 代码的方式。我是编程新手,所以我有点卡住了。任何帮助,将不胜感激。!
<!DOCTYPE html>
<html>
<head>
<title>Pricing</title>
<meta name="viewport" content="width:device-width initial-scale:1.0">
<style>
img{height:auto;
width:fit-content}
</style>
</head>
<body>
<h1 style=font-family:impact;font-size:100px;color:darkblue;text-align:center> Class Fee 2021</h1>
<table style="border: 1px solid black; width:75%;text-align:center">
<tr style="background-color:royalblue;color:white">
<th>Membership Type</th>
<th>Class Limit (Per week)</th>
<th>Weekly Fee</th>
</tr>
<tr>
<td style="padding-left:10px;">basic Memebrship</td>
<td style="padding-left:10px;">3</td>
<td style="padding-left:10px;">50</td>
</tr>
</table>
<img src=boxingback.jpg alt='wallpaper'>
</body>
</html>
解决方案
更改width
为“100%”(而不是width:fit-content
,它不存在)并为标签中的src
属性值使用引号:img
<!DOCTYPE html>
<html>
<head>
<title>Pricing</title>
<meta name="viewport" content="width:device-width initial-scale:1.0">
<style>
img {
height: auto;
width: 100%;
}
</style>
</head>
<body>
<h1 style=font-family:impact;font-size:100px;color:darkblue;text-align:center> Class Fee 2021</h1>
<table style="border: 1px solid black; width:75%;text-align:center">
<tr style="background-color:royalblue;color:white">
<th>Membership Type</th>
<th>Class Limit (Per week)</th>
<th>Weekly Fee</th>
</tr>
<tr>
<td style="padding-left:10px;">basic Memebrship</td>
<td style="padding-left:10px;">3</td>
<td style="padding-left:10px;">50</td>
</tr>
</table>
<img src="https://picsum.photos/seed/picsum/1200/900" alt='wallpaper'>
</body>
</html>
推荐阅读
- reactjs - 无法导航到 / 并得到未定义的错误
- mysql - 统计 SQL 中高于和低于平均分的学生人数
- javascript - 如何使用 JavaScript 切换自定义复选框?
- c# - 天蓝色函数中的并行 Foreach
- mysql - MongoDB - 根据字段在小组阶段是否具有特定值来计数文档
- reactjs - 如何将 Cloud Firestore 与 React Native 和 Redux 一起使用?
- javascript - 如何从一个菜单中获取菜单项并将它们附加到不同的菜单
- python - Python 硒 (html) 复选框
- android - 错误:Gradle 任务 assembleDebug 失败,退出代码为 1
- if-statement - 数组中的 Fiter / IF 函数(谷歌表)