html - 将图像与文本块配对
问题描述
.Spotify:hover img { display:block;
position: absolute;
z-index: 0;
top:17%;
left: 14%;
width: 45%;
height: auto;
}
<a class="Spotify" href="Spotify" rel="history"><img src="https://files.cargocollective.com/c160628/MS_Spotify.png">Spotify</a>
当您将鼠标悬停在我主页上的文本块上时,会出现一个选定的案例研究图像。每个单词/图像都有一段独特的代码。在您调整网站大小或查看移动版本并且图像和文字不再对齐之前,这一切都很好。是否有一段代码可以让我做出响应?因此图像始终与选定的文本块保持一致。(最好图像保持在右对齐字的下方)
解决方案
全屏运行以下代码段,然后切换到移动模式。
基本上,我通过媒体查询查询在移动模式下给图像全宽
.Spotify:hover img {
display: block;
position: absolute;
z-index: 0;
top: 17%;
left: 14%;
width: 45%;
height: auto;
}
img{
display:none;
}
@media(max-width:768px){/*You can change this to any number lesser than this*/
a{
display:block;
position:relative;
}
.Spotify:hover img{
top:120px; /*height of the text on your website*/
left:auto;
right:auto;
bottom:auto;
width:100%;
height:auto
}
}
<a class="Spotify" href="Spotify" rel="history">
<img src="https://files.cargocollective.com/c160628/MS_Spotify.png"/>Spotify
</a>
推荐阅读
- ruby - 预期数组中单个数组的排列
- excel - 在没有空字符串附加的情况下,通过 vba 打开文件夹不起作用
- azure - 使用私有 DockerHub 存储库中的 Terraform 在 Azure 上部署容器
- ruby-on-rails - Rails 启动失败 - 未定义符号:pthread_atfork
- android - 使用手机的游戏控制台中的 512x512 图标问题
- sql - Postgres 不正确的行估计
- c# - Entity Framework Core MVC App中的多对多数据绑定
- microservices - 将 SAGA 模式与同步 HTTP 请求一起使用
- c++ - 将 double 更改为 float 给出相同的答案,但比较后输出意外
- pytorch - 使用 torch.autograd.backward() 传递渐变