首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调整不同尺寸的景观图像大小,使固定的肖像与圆形框架相匹配

问调整不同尺寸的景观图像大小,使固定的肖像与圆形框架相匹配
EN

Stack Overflow用户
提问于 2018-09-05 15:50:27
回答 1查看 56关注 0票数 0

我有几十幅大小不一的景观图片:522x393,496x473,428 x336,359 x 240....etc等。

我想显示他们在一个肖像框架(300 X 340)与一个圆形的裁剪(这成为一个圆形边框悬停)。灵感是从这里来的

​

​

然而,在我的图像中没有一致的维度。我遇到的一个大问题是,当悬停在一些框上时,名称和标题会出现在图像上。但是,在一些不够高的图像上,名称和标题出现在黑色(持有图像的元素的默认背景)上。如果我把我的太小的图片一直向下推,这样的名字/标题总是出现在照片的顶部,脸通常是圆的裁剪。我不知道如何调整我的照片大小,以便:

  1. 名称和标题的背景在悬停时是一致的(照片背景或黑色填充背景)
  2. 脸在圆圈里。

在这里看我的小提琴 HTML:

代码语言:javascript
复制
<div class="team-listing">
        <ul>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/nkzsc7n9d/Aman.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/nkzsc7uz5/CCK.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/6x8a9vktt/Yin.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/5i6pl19f5/Emma.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/jomgge2bl/Yu-_Wei.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/gujb2tptt/Gaurav.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/fs94k8wpt/Guangyu.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/ubg9lo5a9/Ila.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/a42ttdn8h/Ivy.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/3qdqq3v75/Jacky.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/6kgw3kcsx/Jian.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/4fwj2idr5/Joseph.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/hwthldgcx/Neeraj.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/7mr2m5lch/Paul.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/n88e6450h/Peiti.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/8djssdqf5/image.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/sjnaqx6jl/Yu.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/3qdqq6v81/Priyank.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/55fbewold/Qi.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/oaikorb01/Sean.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/4354wfaxt/Yi.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/daxdd2zzl/Steve.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/yxcdu4dzl/Vinay.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/vqhuahltt/Vincent.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/agu7zo0e9/Wei.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/4fwj2l629/Weikang.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/atlm5u38h/Wei_An.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
          <li>
            <svg width="0" height="0">
          <clipPath id="circle">
              <circle cx="150" cy="150" r="100"></circle>
          </clipPath>
      </svg>
            <a href="#">
              <article>
                <svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
      <!-- no automatic sizing for SVG image, width and height must be set -->
              <image width="300" height="340" x="0" y="-20" xlink:href="https://s22.postimg.cc/epyy1v68h/Wenxin.jpg.jpg"></image>
              <circle class="ring" cx="150" cy="150" r="100"></circle>
          </svg>
                <div class="bio">
                  <h2>Chun-Kang Chen</h2>
                  <h4>Article Subtitle</h4>
                </div>
              </article>
            </a>
          </li>
        </ul>
      </div>
EN

回答 1

Stack Overflow用户

发布于 2018-09-05 16:59:49

正如@Paulie_D所提到的,最好的情况(通常也是标准的情况)是,您将照片裁剪为具有一致和相似的面部位置,这将有效地解决您的两个问题一下子。但是,除非这样做:

定位文本将相对笔直,与一些创造性定位的基础上的圆圈,并使用一些溢出容器。但你的大问题是以脸为焦点。有一些面部识别API可以让你找到人脸的近似中心,比如Face-API.js和Tracking.js。这样你就可以相对地将图像定位在圆形面罩后面,固定在他们脸的中心。

然而,你可以看到这是在哪里自找麻烦。任何它不认识的面孔都需要一个后备或覆盖,更不用说学习一个新的库了(我认为这不一定是件坏事)。

老实说,因为只有26张照片,如果你只花了5分钟的时间来裁剪它们,你可能会过得更好,也会得到更一致的结果。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52189132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档