【问题标题】:Hyperlinked image not clickable on smaller screens在较小的屏幕上无法点击超链接图像
【发布时间】:2017-10-12 05:26:18
【问题描述】:

我有一个带有超链接的图像,当小屏幕的 css 启动时,该超链接变得无法点击。我不知道为什么!

这是页面:https://jupacharge.com/pages/become-a-reseller

这是页面本身的 HTML,有问题的图片/链接标有 **

<div class="reseller_container">
<div class="reseller_header">BECOME A RESELLER</div>
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-reseller-background.png?12251079152443546141" />
<p>We're always on the lookout for <b>BUSINESSES OR INDIVIDUALS</b> who would like to <b>BUILD A RELATIONSHIP</b> with JUPA, whether that's <b>RESELLING</b> our charger or <b>ANYTHING ELSE</b>. If you feel this would be something for you then please <b>GET IN TOUCH</b> with us.</p>
**<a href="http://www.jupacharge.com/pages/contact"><img class="contact_button" src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-get-in-touch.png?15833297944705309626" /></a>**
<div class="reseller_text">We will aim to respond to your enquiry within 1 business day</div>
</div>
<img class="deal_icon" src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-deal.png?15833297944705309626" />

这是它背后的 CSS,特别是

@media (min-width:600px) {

  .reseller_container {
    display: inline-block;
    position: relative;
  }

  .reseller_container p {
    position:absolute; 
    top: 17%;
    left: 10%;
    bottom: 0;
    right: 0;
    color: #000000;
    font-size: 3.5vmin;
    font-family: $bodyFontStack; 
    text-align:center;
    width:80%;
  }

  .reseller_text {
    position:absolute; 
    top: 95%;
    left: 0;
    bottom: 0;
    right: 0;
    color: #000000;
    font-size: 2vmin;
    font-family: $bodyFontStack; 
    text-align:center;
  }

  .reseller_header {
    position:absolute; 
    top: 5%;
    left: 0;
    bottom: 0;
    right: 0;
    color: #66BD00;
    font-size: 8vmin;
    font-family: ubuntu;
    font-weight:bold;
    text-align:center;
  }

  .reseller_container a {
    color:#66BD00;
  }

  .contact_button {
    display: block;
    position: absolute;
    top: 89%;
    left: 30%;
    bottom: 0;
    right: 0;
    z-index: 1;
    width: 40%;
  }

  .deal_icon {
   display:none;
  }

}

@media (max-width:600px) {

  .reseller_container {
    display: inline-block;
    position: relative;
  }

  .reseller_container p {
    color: #000000;
    font-size: 4vmin;
    font-family: $bodyFontStack; 
    text-align:center;
    width:100%;
  }

  .reseller_text {
    color: #000000;
    font-size: 2.5vmin;
    font-family: ubuntu; 
    text-align:center;
  }

  .reseller_header {
    position:absolute; 
    top: 4%;
    left: 0;
    bottom: 0;
    right: 0;
    color: #66BD00;
    font-size: 12vmin;
    font-family: ubuntu;
    font-weight:bold;
    text-align:center;
    line-height: 1em;
  }

  .reseller_container a {
    color:#66BD00;
  }

  .contact_button {
   display:block;
   margin:auto;
   width:80%;
   padding-bottom:5px;
  }

  .deal_icon {
   display:block;
   margin:auto;
   width:20%;
  }

}

任何帮助将不胜感激。

【问题讨论】:

    标签: html css image hyperlink


    【解决方案1】:

    这是因为以下规则。删除bottom: 0,你应该没问题。这是一个溢出问题。

    @media (max-width: 600px) {
      .reseller_header {
        position: absolute;
        top: 4%;
        left: 0;
        bottom: 0; /* remove this */
        right: 0;
        color: #66BD00;
        font-size: 12vmin;
        font-family: ubuntu;
        font-weight: bold;
        text-align: center;
        line-height: 1em;
      }
    }
    

    【讨论】:

    • 谢谢!这是一个非常容易解决的问题。我会投票,难道它不允许我。
    【解决方案2】:

    对于小于 600 像素的 CSS,您需要将标题的高度设置为 0。它会在较低分辨率下与您的内容重叠。但是在同一个地方,当它超过 600px 时,它在开发工具中重叠,但链接是可点击的。

    不管怎样,这是代码:

    @media (max-width:600px) {
    
        ...
    
        .reseller_header {
            position:absolute; 
            height: 0;
            top: 4%;
            left: 0;
            bottom: 0;
            right: 0;
            color: #66BD00;
            font-size: 12vmin;
            font-family: ubuntu;
            font-weight:bold;
            text-align:center;
            line-height: 1em;
        }
    
        ...
    
    }
    

    【讨论】:

    • 谢谢!也试过了,效果很好,虽然我使用了下面的方法,因为它少了 2 行 CSS。
    猜你喜欢
    • 2020-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-18
    • 2011-07-08
    • 2019-04-16
    • 2022-08-19
    • 1970-01-01
    相关资源
    最近更新 更多