站点范围的导航链接在一个页面上响应而不是另一个页面

时间:2015-10-21 04:47:51

标签: html css ruby-on-rails sass materialize

我正在铁轨上构建一个网站,并实施了一个站点范围的导航栏以显示在所有页面上。问题是它出现在两个页面上,但是链接和悬停状态只能在一个页面上单击吗?当我渲染相同的_navigation.html.erb和nav.scss文件时,我无法弄清楚出了什么问题?

_navigation.html.erb

<nav>
  <div class="container nav-container">
    <div class="row">
      <div class="nav-wrapper">
        <a href="#" id="brand-logo" class="col l2"><img src="<%= asset_path('social-playground-logo.png')%>"></a>
          <ul id="nav-mobile" class=" col l10 right hide-on-med-and-down nav-desktop">
            <li><a id="link-home" href="">Home</a></li>
            <li><a id="link-toys" href="">Toys</a></li>
            <li><a id="link-pastevents" href="">Past Events</a></li>
            <li><a id="link-contacts" href="">Contacts</a></li>
            <li><a id="link-partners" href="">Partners</a></li>
          </ul>
      </div>
    </div>
  </div>

gifpage.html.erb navbar和hero-image提取(正常工作)

<div class="hero-image-container group">
    <%= render 'layouts/navigation' %>
    <img id="gif-foreground-hero" src="<%= asset_path( 'GIF Foreground FInal.png') %>" class="responsive-img">

selfies.html.erb navbar和hero-image提取(不能正常工作)

<div class="selfies-hero-image-container group">
    <%= render 'layouts/navigation' %>
    <img id="selfie-foreground-hero" src="<%= asset_path( 'Selfie-hero-foreground.png') %>" class="responsive-img">

_nav.scss

nav {
    height: 112px;
    line-height: 23px;
    background: rgba(10, 10, 10, 0.5);

    .nav-container {
        width: 100%;

        #brand-logo {
            transform: scale(0.8);
            margin-top: 7px;
            margin-left: 4%;
        }

        #nav-mobile {
            margin-right: 0%;
            margin-left: 0%;
            width: 79.33333%;
        }

        ul li {
            margin-top: 27px;
            margin-left: 29px;

            a {
                text-transform: uppercase;
                border: 4px solid rgba(255, 255, 255, 0);
                margin: 0px;
                padding: 14px 25px;
                display: inline-block;

                &:hover {
                    border: 4px solid rgba(255, 255, 255, 1);
                }
            }
        }
    }

}

边框显示在:悬停在gif页面上,但不是自拍。

谢谢你们Both hero images to appear beneath a 0.5 opacity navbar

The blue kero image is the page not working

两个英雄图像都通过导航栏显示,其中0.5不透明度。

由于

修改

从终端打印输出

Started GET "/gifpage" for 59.167.19.225 at 2015-10-21 05:30:23 +0000
Cannot render console from 59.167.19.225! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by PagesController#gifpage as HTML
  Rendered layouts/_navigation.html.erb (0.5ms)
  Rendered pages/gifpage.html.erb within layouts/application (62.3ms)
  Rendered layouts/_footer.html.erb (0.0ms)
Completed 200 OK in 445ms (Views: 444.1ms | ActiveRecord: 0.0ms)

用,

Started GET "/assets/_nav-87ab5873b40bcbbebe26b4faa985fc95.css?body=1" 

作为为正在工作的页面呈现的_nav.scss文件, 和,

Started GET "/" for 59.167.19.225 at 2015-10-21 05:34:25 +0000
Cannot render console from 59.167.19.225! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by PagesController#selfies as HTML
  Rendered layouts/_navigation.html.erb (0.9ms)
  Rendered pages/selfies.html.erb within layouts/application (8.0ms)
  Rendered layouts/_footer.html.erb (0.0ms)
Completed 200 OK in 410ms (Views: 408.8ms | ActiveRecord: 0.0ms)

用,

Started GET "/assets/_nav-87ab5873b40bcbbebe26b4faa985fc95.css?body=1"

正在呈现页面无法正常工作。

我还在chrome检查元素中并排比较了css和结构,两者完全相同。仍然不知道!

2 个答案:

答案 0 :(得分:0)

查看源代码,看看资产管道是否呈现了相同的.css文件;也许不同的控制器有不同的CSS文件。或者,inspect元素将显示为每个加载的css。也许你也在按照LVHA的css顺序(link / visited / hover / active)。

答案 1 :(得分:-1)

谢谢你的回答。今天我解决了这个问题。英雄形象实际上是坐在导航列表项目上,因此完全使悬停动作无效(即浏览器读取它时我将鼠标悬停在图像而不是导航栏上)。将图像的z-index更改为1并将导航栏的z-index更改为2可解决此问题。当我将鼠标悬停在导航栏上时,浏览器现在读取它,图像后面有一层图层。在尝试了一切之后,我决定从头开始再次构建页面,除了这个时候,无论出于何种原因,我使叠加的图像变得更小。这导致悬停操作仅出现在导航栏的外部,而不是其余部分,导致我解决问题。

再次感谢, 贾斯汀