没有 iPhone , win10 能测试 iPhone 网页显示效果么?

322 天前
 libasten

我做了一个博客网站,“高仿朋友圈”。 9 宫格的方法是先将 9 个 img 排 3 排,用原生 JS 获取单张照片的宽度,然后再把高度设置为宽度一样,这样就得到正方形效果了。 我这有个 iPhone 14 pro 看正常,安卓也正常,有个朋友用的 iPhone 13 ,说图片被拉成长柱子了,手边没有 13 的机器,咋测试呢?

图片样式代码是这样,兼容性有问题吗?

/*  5 张以上图片  */
.grid-pics img:nth-child(1):nth-last-child(n + 5),
.grid-pics img:nth-child(1):nth-last-child(n + 5)~img {
    width: 32%;
    margin-bottom: 1%;
}
var lstPicItem = document.querySelectorAll("#article .pic-item");
    if (lstPicItem.length > 0) {
        lstPicItem.forEach(x => {
        x.style.height = lstPicItem[0].width + 'px';
    })
}

页面网址是: https://www.feidaoboke.com/pyq/

591 次点击
所在节点    问与答
4 条回复
TRW
322 天前
腾讯云真机
Corolin
322 天前
尝试一下 css 解决咯?

.grid-pics {
display: grid;
grid-template-columns: repeat(3, 1fr);
}

.grid-pics .img {
aspect-ratio: 1;
background-repeat: no-repeat;
background-size: cover;
}

<div class="img" style="background-image: url( https://www.feidaoboke.com/pyq/zb_users/upload/demoImg/1.jpg);"></div>
forgottencoast
322 天前
Chrome 的 F12 能模拟手机,试试看?
0ranger
322 天前

这个 ok 不

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/954921

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX