javascript - 如何在导航栏 html + css 中使图像响应
问题描述
我正在使用此代码
<div>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<div class="d-flex flex-row justify-content-center align-items-center">
<a class="navbar-brand" href="#">
<img class="img-logo" src="https://www.instagram.com/static/images/web/mobile_nav_type_logo.png/735145cfe0a4.png" alt="" loading="lazy" style="width:12%;height:auto; float: left;">
<h1 style="color: #89216b; float: right; margin-top: auto; margin-bottom: auto; font-size: all;">Trendings</h1>
</a>
</div>
</div>
</nav>
</div>
一切都很完美,但是当我在移动设备上看到它时,图像尺寸很小,文字尺寸保持不变,我只是希望图像尺寸不会很小
解决方案
当您在img中使用width:12%时,它会自动使图像变小。因此,我建议您删除该代码并改用该代码;
.navbar-brand{
width:100%;
height:auto;
}
.img-logo{
max-width:100%;
height:auto;
object-fit:cover;
}
同样在您的 html 中;(我删除了样式中的宽度和高度)
<img class="img-logo" src="https://www.instagram.com/static/images/web/mobile_nav_type_logo.png/735145cfe0a4.png" alt="" loading="lazy" style="float: left;">
推荐阅读
- firebase - 将 Firebase Crashlytics SDK 列入白名单
- android - Recyclerview 选择:createSelectSingleAnything 滚动时选择多个
- google-apps-script - 调用库中的另一个函数时,内部函数出现语法错误
- java - 我在java中使用jopendocument解析ods文件合并单元格有冲突吗?
- java - 骆驼 - 试图达到终点
- c# - C# xml 站点地图如何从 url 部分消除 xmlns
- c++ - 如何使用 IExecuteCommand 和动词在上下文菜单外壳扩展中显示本地化文本和自定义图标?
- gtsummary - 如何修改“gtsummary”中“all_categorical()”定义的默认变量类型?什么时候需要序数变量的平均值?
- unity3d - TimeSpan 的自定义 PropertyDrawer,问题设置 SerializedProperty longValue
- java - 如何使用 ArrayList 获取 TextField 输入