内部链接
  • 没有工作
  • 发布于 2024-12-13 09:24:37 字数 1304 浏览 1 评论 0原文

    我正在尝试破解非常简单的坚果。我仅使用 CSS 进行图像翻转。当我插入 a href 链接时,它不起作用。我所说的“不起作用”是指它不像一个链接,因此您无法点击进入该页面。认为它与

  • 有关,但我不知道是什么。这是我的 HTML 和 CSS:
  • CSS

        ul.navigation,
        ul.navigation ul {
        margin: 25px 0 0 0;
        }
        ul.navigation li {
        list-style-type: none;
        margin:15px;
      }
    
    .AboutUsNav{
        display: block;
        width: 159px;
        height: 54px;
        background: url('../images/N_About_Us.png') bottom;
        text-indent: -99999px;
    }
    .AboutUsNav:hover {
        background-position: 0 0;
    }
    

    HTML

    <div>
    <ul class="navigation">
    <li class="AboutUsNav"><a href="/about">About Phin &amp Phebes Ice Cream</a></li>
    <li class="FlavorsNav"><a href="/flavors">Ice Cream Flavors</a></li>
    <li class="WheretoBuyNav"><a href="/buy">Where to Buy Our Ice Cream</a></li>
    <li class="WholesaleNav"><a href="/wholesale">Wholesale Orders Ice Cream</a></li>
    <li class="ContactUsNav"><a href="/contact">Contact Phin &amp; Phebes Ice Cream</a></li>
    <li><a href="http://phinandphebes.com/about">about</a></li>
    
    </ul>
    </div>
    

    Pretty simple nut I'm trying to crack. I'm doing image rollovers with CSS only. When I plugged in my a href link, it just does not work. By not work I mean, it does not act like it's a link and as a result you cannon click through to the page. Figuring it has something to do with the <li> but I can't figure out what. Here's my HTML and CSS:

    CSS

        ul.navigation,
        ul.navigation ul {
        margin: 25px 0 0 0;
        }
        ul.navigation li {
        list-style-type: none;
        margin:15px;
      }
    
    .AboutUsNav{
        display: block;
        width: 159px;
        height: 54px;
        background: url('../images/N_About_Us.png') bottom;
        text-indent: -99999px;
    }
    .AboutUsNav:hover {
        background-position: 0 0;
    }
    

    HTML

    <div>
    <ul class="navigation">
    <li class="AboutUsNav"><a href="/about">About Phin & Phebes Ice Cream</a></li>
    <li class="FlavorsNav"><a href="/flavors">Ice Cream Flavors</a></li>
    <li class="WheretoBuyNav"><a href="/buy">Where to Buy Our Ice Cream</a></li>
    <li class="WholesaleNav"><a href="/wholesale">Wholesale Orders Ice Cream</a></li>
    <li class="ContactUsNav"><a href="/contact">Contact Phin & Phebes Ice Cream</a></li>
    <li><a href="http://phinandphebes.com/about">about</a></li>
    
    </ul>
    </div>
    

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(3

    无可置疑 2024-12-20 09:24:37

    您的 .AboutUsNav 具有 text-indent: -99999px;,将 a 拉到可点击视口之外。

    您可能希望将负的 text-indent 放在 a 本身上,然后将 a 元素设置为 display: block;宽度:100%; height: 100%,根据您的情况而定。

    Your .AboutUsNav has text-indent: -99999px;, pulling the a outside of the clickable viewport.

    You probably want to put the negative text-indent on the a itself, and then set the a element to display: block; width: 100%; height: 100%, depending on your circumstances.

    享受孤独 2024-12-20 09:24:37

    不要将文本缩进和背景应用于列表 - 而是将其应用于链接。

    示例:

    <div id=​"main_nav">
        <li class="home">
            <a href="/">Home</a>
        </li>
        <li class="news">
            <a href="/">News</a>
        </li>
    </div>
    

    CSS:

    #main_nav a {
        background-image:url();
    }
    #main_nav .home a {
        width: 82px;
        background-position: 0px 0px;
    }
    #main_nav .news a {
        width: 85px;
        background-position: 82px 0px;
    }
    

    don't apply the text-indent and background to the list - do it to the link instead.

    Example:

    <div id=​"main_nav">
        <li class="home">
            <a href="/">Home</a>
        </li>
        <li class="news">
            <a href="/">News</a>
        </li>
    </div>
    

    CSS:

    #main_nav a {
        background-image:url();
    }
    #main_nav .home a {
        width: 82px;
        background-position: 0px 0px;
    }
    #main_nav .news a {
        width: 85px;
        background-position: 82px 0px;
    }
    
    孤独陪着我 2024-12-20 09:24:37

    感谢您的帮助。我尝试了你们推荐的方法。我认为这在某些情况下绝对有效。对我来说,我的背景图像没有显示,但链接有效。

    我最终通过保持 CSS 不变但更改 HTML 标记来解决这个问题,如下所示:

    <div>
    <ul class="navigation">
        <li><a class="AboutUsNav" href="/about">About Phin & Phebes Ice Cream</a></li>
        <li><a class="FlavorsNav" href="/flavors">Phin & Phebes Flavors</a></li>
        <li><a class="WheretoBuyNav" href="/buy">Where to Buy Phin & Phebes Ice Cream</a></li>
        <li><a class="WholesaleNav" href="/wholesale">Wholesale Orders Ice Creamf</a></li>
        <li><a class="ContactUsNav" href="/contact">Contact Phin & Phebes Ice Cream</a></li>
    </ul>
    

    我正在制作这个演示,其中不包含无序列表: http: //kyleschaeffer.com/best-practices/pure-css-image-hover/

    thank you for your help. I tried the approach you both recommended. I think this definitely works under certain circumstances. For me, my background image just wasn't showing up but the links were working.

    I ended up solving this problem by leaving the CSS the same but changing the HTML markup as so:

    <div>
    <ul class="navigation">
        <li><a class="AboutUsNav" href="/about">About Phin & Phebes Ice Cream</a></li>
        <li><a class="FlavorsNav" href="/flavors">Phin & Phebes Flavors</a></li>
        <li><a class="WheretoBuyNav" href="/buy">Where to Buy Phin & Phebes Ice Cream</a></li>
        <li><a class="WholesaleNav" href="/wholesale">Wholesale Orders Ice Creamf</a></li>
        <li><a class="ContactUsNav" href="/contact">Contact Phin & Phebes Ice Cream</a></li>
    </ul>
    

    I was working off this demo, which didn't include an unordered list: http://kyleschaeffer.com/best-practices/pure-css-image-hover/

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文