html - 在手机上查看时图像消失

标签 html css

目前我正在尝试使社交按钮可见但不同于桌面 View 。我的 HTML 是:

#facebook {
    position: fixed;
    top: 47vw;
    left: 50vw;
}
    
#facebook img {
    width: auto; 
    height: 1.25vw;
    position: absolute;
}
    
@media only screen and (max-width: 768px) {
    #facebook img { 
        width: auto; 
        height: 4.5vw;
        position: absolute;
    }

@media only screen and (max-width: 768px) {
    #facebook { 
        top: 160vw;
        left: 50vw;
    }
}
<a href="https://www.facebook.com/" target="_blank">
    <div id="facebook">
        <img class="fb" src="images/facebook.png" alt="Facebook" />
    </div>
</a>

编辑:通过将 vw 更改为百分比来修复它

最佳答案

你的错误在于:

#facebook { 
    top: 160vw;
    left: 50vw;
}

将其更改为:

#facebook { 
    top: 0vw;
    left: 0vw;
}

将顶部设置为 160 视口(viewport)宽度显然会将整个内容移出屏幕

关于html - 在手机上查看时图像消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46815650/

相关文章:

javascript - 如何将表格放在像坐标系一样的图像轮播上?

javascript - 有人可以向我解释这段 CSS 代码吗?

html - 右对齐 flex 元素并垂直居中其内容

html - 跳过表格中奇数行和偶数行中的某些行——连续的 CSS 样式

javascript - Phonegap Jquery 移动表单提交刷新

html - 负边距 "hovering"div 在后面的元素下

html - 为什么这个div完全坏了?

javascript - 如何使用页面滚动修复页眉+表头和滚动表体和页脚

html - 当我将按钮的宽度和高度更改为较小的数字时,按钮中的内联图标未居中

html - 在 res.sendfile express js 上发送 html 和 css 文件