【问题标题】:Responsive PhotoSwipe with large controls on mobile device在移动设备上具有大型控件的响应式 PhotoSwipe
【发布时间】:2015-12-09 19:54:59
【问题描述】:

在这个官方的 codepen 中,在我的移动设备上,控件和标题看起来非常小: http://codepen.io/dimsemenov/pen/ZYbPJM

我尝试将其添加到 HTML 中,但没有任何区别:

    <meta name="viewport" content="width = device-width, initial-scale = 1.0"> 

我怎样才能让它们像 photoswipe.com 网站那样变大?

【问题讨论】:

    标签: javascript jquery photoswipe


    【解决方案1】:

    如果您的标记看起来像 PhotoSwipe 网站和 CodePen 上建议的那样,您可以简单地在 figcaption 元素中添加您喜欢的任何 HTML 元素,如下所示:

    <div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery">
        <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
            <a href="img/dektop/1.jpg" itemprop="contentUrl" data-size="1200x1202">
                <img src="img/thumb/1.jpg" itemprop="thumbnail" alt="Image description" />
            </a>
                <figcaption itemprop="caption img-description">
                <div class="index">
                    <div class="img-title">
                        Title of the image or photo
                    </div>
                    <div class="img-year">
                        2003
                    </div>
                    <div class="dimensions">
                        1200 x 900 cm
                    </div>
                    <div class="technique">
                        Oil on cotton
                    </div>
                </div>
                </figcaption>
        </figure>
    

    然后使用下面的 CSS 来设置标题的样式,例如:

    .img-title {
        font-size: 2em;
    }
    
    .img-year {
        font-size: 1.2em;
    }
    
    .dimensions {
        font-size: 1em;
    }
    
    .technique {
        font-size: 0.8em;
    }
    

    然后,如果您对默认值不满意,您还可以将媒体查询添加到手机和平板电脑标题的样式类中。

    @media screen and (min-width:0px) {
        .img-title {
            font-size: 2em;
        }
    
        .img-year {
            font-size: 1.2em;
        }
    
        .dimensions {
            font-size: 1em;
        }
    
        .technique {
            font-size: 0.8em;
        }              
    }
    
    
    @media screen and (min-width:320px) {
        .img-title {
            font-size: 4em;
        }
    
        .img-year {
            font-size: 2.2em;
        }
    
        .dimensions {
            font-size: 1.5em;
        }
    
        .technique {
            font-size: 1.1em;
        }              
    }   
    

    记得包含所有 JS 和 CSS 文件,如下所示:
    http://photoswipe.com/documentation/getting-started.html

    <!-- Core CSS file -->
    <link rel="stylesheet" href="path/to/photoswipe.css"> 
    
    <!-- Skin CSS file (styling of UI - buttons, caption, etc.)
         In the folder of skin CSS file there are also:
         - .png and .svg icons sprite, 
         - preloader.gif (for browsers that do not support CSS animations) -->
    <link rel="stylesheet" href="path/to/default-skin/default-skin.css"> 
    
    <!-- Core JS file -->
    <script src="path/to/photoswipe.min.js"></script> 
    
    <!-- UI JS file -->
    <script src="path/to/photoswipe-ui-default.min.js"></script> 
    

    我也遇到了这个问题PhotoSwipe: edit parseThumbnailElements function to parse additional markup element 并将其链接给您,以了解如何使用 PhotoSwipe 项目以及您在问题中链接的 CodePen 中使用的这个确切的 HTML 标记构建响应式画廊网格。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-22
      • 2013-02-10
      • 2016-10-14
      • 2013-07-28
      相关资源
      最近更新 更多