libasten
V2EX  ›  问与答

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

  •  
  •   libasten · Jul 7, 2023 · 1382 views
    This topic created in 1083 days ago, the information mentioned may be changed or developed.

    我做了一个博客网站,“高仿朋友圈”。 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/

    4 replies    2023-07-07 19:39:36 +08:00
    TRW
        1
    TRW  
       Jul 7, 2023
    腾讯云真机
    Corolin
        2
    Corolin  
       Jul 7, 2023
    尝试一下 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
        3
    forgottencoast  
       Jul 7, 2023
    Chrome 的 F12 能模拟手机,试试看?
    0ranger
        4
    0ranger  
       Jul 7, 2023

    这个 ok 不
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3071 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 88ms · UTC 14:30 · PVG 22:30 · LAX 07:30 · JFK 10:30
    ♥ Do have faith in what you're doing.