首页 \ 问答 \ 仅隐藏在固定透明导航栏后面滚动的元素部分(Hiding only the part of an element that scrolls behind a fixed transparent nav bar)

仅隐藏在固定透明导航栏后面滚动的元素部分(Hiding only the part of an element that scrolls behind a fixed transparent nav bar)

我已经搜索了很多答案,发现了很多类似的问题,但没有找到适合我的解决方案。 我可能只是错过了一些非常明显的东西。

我有一个固定的透明导航栏,距离顶部40px。

问题是什么以及我想要实现的目标:

我有视差滚动和导航栏看起来很好,透明元素在图像上,但滚动文本时看起来很糟糕。

我想隐藏在包含文本.About.Portfolio.Portfolio的三个部分中与导航栏冲突的文本,或仅隐藏导航栏后面的位。

我刚刚发现这种解决方案可以解决问题,但我认为看起来仍然有点笨拙。 向下滚动时隐藏透明固定导航栏下的内容

$(document).ready(function() {
  $(document).scroll(function() {
    $(".About p, .Portfolio p, .Contact p, .About h3, .Portfolio h3, .Contact h3 ").each(function() {
      if ($(this).offset().top <= $(document).scrollTop() + 5) {
        $(this).css("opacity", "0");
      } else {
        $(this).css("opacity", "1");
      }
    });
  });
});

也许如果有一种方法可以包含fadeOut或逐行选择文本。 当文本堆叠成更多行时,这在较低分辨率下看起来特别糟糕,并且它们一下子消失,留下更大的空白区域。

这是nav Html:

    <nav>
        <ul>
            <li><a id="title" title="Charlie Day" href="#top" aria-haspopup="true">CHARLES DAY</a></li>

            <li><a class="anchor" title="About" href="#About" aria-haspopup="true">About </a></li>

            <li><a class="anchor" title="Portfolio" href="#Portfolio" aria-haspopup="true">Portfolio</a></li>

            <li><a class="anchor" title="Contact" href="#Contact" aria-haspopup="true">Contact</a></li>
        </ul>
    </nav>

以下是CSS的相关内容:

nav {
background-color: rgba(255,255,255,0.5);
position: fixed;
top: 0px; left: 0px;
width: 100%;
height: 40px; 
z-index: 300;
font-size: 1.1em;
font-weight: 400;
}

nav::after { content: ''; display: block; clear: both; }

nav ul { list-style: none; margin: 0; padding: 0; }

nav ul li:hover {background-color: rgba(200,200,200,.5); }
nav ul li:hover > ul { display: block; }
nav ul li a {
display: inline-block;
color: black;
padding: 10px 20px;
text-decoration: none;
width: 125px;
position: relative;
}
a#title {font-weight: 700; }


/*top-level*/
nav > ul  { padding-left: 0px; margin-left: -10px; }    
nav > ul > li { float: left; }
nav > ul > li > a { width: auto; padding: 10px 20px 14px 20px; }

我刚试过这个:

$(document).ready(function() {
  $(document).scroll(function() {
    $(".About p, .Portfolio p, .Contact p, .About h3, .Portfolio h3, .Contact h3 ").each(function() {
      if ($(this).offset().top <= $(document).scrollTop() + 6) {
        $(this).fadeOut() }, 500);
      } else {
        $(this).fadeIn() }, 500);
      }
    });
  });
});

但它似乎根本不起作用。

真正好的是,如果只有文本内容在距离顶部正好40px处变得不可见或隐藏等,那么只有40px以上的文本部分被隐藏,但是仍然可以看到低于40px的任何内容。

目前JS解决方案的视频: https//vimeo.com/148953772

在这里您可以看到重叠: 重叠文本

Z-index解决方案可以正常工作,但目前它不适合我的网站,因为图像被设置为背景,包含内容的部分滚动到顶部(视差滚动),所以我将无法z-索引图像背后的文字。 也许一个响应的div只能在某个时刻激活才能解决这个问题?


I have searched a lot for an answer to this and have found lots of similar issues but haven't managed to find a solution that works for me. I'm probably just missing something very obvious.

I have a fixed transparent nav bar that is 40px from the top.

What the problem is and what I want to achieve:

I have parallax scrolling and the nav bar looks great with the transparent element over the images, however it looks awful when scrolling past text.

I would like to hide only the text which conflicts with the nav bar in the three sections that contain text .About, .Portfolio and .Contact, or only the bit that is behind the nav bar.

I have just found this solution which sort of solves the problem, but I think still looks a bit clunky. Hide the content under transparent fixed navbar while scrolling down

$(document).ready(function() {
  $(document).scroll(function() {
    $(".About p, .Portfolio p, .Contact p, .About h3, .Portfolio h3, .Contact h3 ").each(function() {
      if ($(this).offset().top <= $(document).scrollTop() + 5) {
        $(this).css("opacity", "0");
      } else {
        $(this).css("opacity", "1");
      }
    });
  });
});

Perhaps if there is a way to include a fadeOut or select the text line by line. This looks especially bad at lower resolutions when the text stacks up into more lines, and it all disappears at once leaving a larger white space.

Here is the nav Html:

    <nav>
        <ul>
            <li><a id="title" title="Charlie Day" href="#top" aria-haspopup="true">CHARLES DAY</a></li>

            <li><a class="anchor" title="About" href="#About" aria-haspopup="true">About </a></li>

            <li><a class="anchor" title="Portfolio" href="#Portfolio" aria-haspopup="true">Portfolio</a></li>

            <li><a class="anchor" title="Contact" href="#Contact" aria-haspopup="true">Contact</a></li>
        </ul>
    </nav>

And here is the relevant bits of CSS:

nav {
background-color: rgba(255,255,255,0.5);
position: fixed;
top: 0px; left: 0px;
width: 100%;
height: 40px; 
z-index: 300;
font-size: 1.1em;
font-weight: 400;
}

nav::after { content: ''; display: block; clear: both; }

nav ul { list-style: none; margin: 0; padding: 0; }

nav ul li:hover {background-color: rgba(200,200,200,.5); }
nav ul li:hover > ul { display: block; }
nav ul li a {
display: inline-block;
color: black;
padding: 10px 20px;
text-decoration: none;
width: 125px;
position: relative;
}
a#title {font-weight: 700; }


/*top-level*/
nav > ul  { padding-left: 0px; margin-left: -10px; }    
nav > ul > li { float: left; }
nav > ul > li > a { width: auto; padding: 10px 20px 14px 20px; }

I have just tried this:

$(document).ready(function() {
  $(document).scroll(function() {
    $(".About p, .Portfolio p, .Contact p, .About h3, .Portfolio h3, .Contact h3 ").each(function() {
      if ($(this).offset().top <= $(document).scrollTop() + 6) {
        $(this).fadeOut() }, 500);
      } else {
        $(this).fadeIn() }, 500);
      }
    });
  });
});

but it doesn't seem to work at all.

What would be really nice is if only the text content became invisible or hidden etc at exactly 40px from the top, so that only the part of the text that is above the 40px is hidden but anything left below 40px is still visible.

video of how it looks at present with JS solution: https://vimeo.com/148953772

Here you can see the overlap:overlapping text

The Z-index solution would work normally, but at the moment it wont for my site as the images are set as background and the sections containing the content scroll over the top (parallax scrolling) of this so I would not be able to z-index the text behind the image. Maybe a responsive div that only activates at a certain point could get around this?


原文:https://stackoverflow.com/questions/34277781
更新时间:2023-09-09 17:09

最满意答案

bool checkForSubnetEquality(in_addr_t ipA, in_addr_t ipB, uint32_t subnetMask) {
   return (ipA & subnetMask) == (ipB & subnetMask);
}

bool checkForSubnetEquality(in_addr_t ipA, in_addr_t ipB, uint32_t subnetMask) {
   return (ipA & subnetMask) == (ipB & subnetMask);
}

相关问答

更多
  • 这是Classless Inter-Doman路由表示法。 / 24表示子网的路由前缀长度为24位,这意味着子网本身剩下8位,即123.218.44.0至123.218.44.255 That's Classless Inter-Doman Routing notation. The /24 means that the routing prefix of the subnet is 24 bits long, which means there's ony 8 bits left for the subn ...
  • 在Python 3.3+中,您可以使用ipaddress模块: >>> import ipaddress >>> ipaddress.ip_address('192.0.43.10') in ipaddress.ip_network('192.0.0.0/16') True 如果您的Python安装超过3.3,您可以使用此回送 。 如果你想以这种方式评估很多 IP地址,你可能需要预先计算网络掩码,例如 n = ipaddress.ip_network('192.0.0.0/16') netw = int( ...
  • bool checkForSubnetEquality(in_addr_t ipA, in_addr_t ipB, uint32_t subnetMask) { return (ipA & subnetMask) == (ipB & subnetMask); } bool checkForSubnetEquality(in_addr_t ipA, in_addr_t ipB, uint32_t subnetMask) { return (ipA & subnetMask) == (ipB & ...
  • 这应该完成你描述的程序。 string ipAddress = "192.168.1.57"; string subNetMask = "255.255.0.0"; string[] ipOctetsStr = ipAddress.Split('.'); string[] snOctetsStr = subNetMask.Split('.'); if (ipOctetsStr.Length != 4 || snOctetsStr.Length != 4) { throw new ArgumentE ...
  • 看看netaddr软件包。 它已经内置了对理解网络掩码的支持,并且能够生成任意期望长度的子网列表: >>> n = netaddr.IPNetwork('10.10.8.0/22') >>> list(n.subnet(24)) [IPNetwork('10.10.8.0/24'), IPNetwork('10.10.9.0/24'), IPNetwork('10.10.10.0/24'), IPNetwork('10.10.11.0/24')] >>> [str(sn) for sn in n.subne ...
  • 你不是在谈论两个子网,而是一个包含16位的B级子网,即 5.248.0.0/16 You are not talking about two subnets, but rather a B-class subnet containing 16-bits, i.e. 5.248.0.0/16
  • 我想这就是你的意思? 但我认为你的38是不正确的。 10.10.155.59 = 00001010.00001010.10011011.00111011 所以B类网络是/ 16,你有一个/ 21网络。 所以你会得到这个: 00001010.00001010 - 10.10 = Network ID (16 bits) 10011 - 19 = Subnet ID (5 bits) 01100111011 - 827 = Host ID (11 bits) 还看看这里 。 I think this is ...
  • 您应该使用group by expression name 。 select -- locate( '.', ip, locate( '.', ip, locate( '.', ip ) + 1 ) + 1 ) as l, substr( ip, 1, locate( '.', ip , locate( '.', ip , locate( '.', ip ) + 1 ) + ...
  • 用番石榴: int slash = Integer.bitCount( ~Ints.fromByteArray( InetAddresses.forString("0.0.0.255").getAddress())); 使用Java 8: int slash = Arrays.stream("0.0.0.255".split("\\.")) .mapToInt(Integer::parseInt) .map(i -> ~i & ...
  • 你本身没有做错任何事; 你只是使用易于使用的集合,而不是处理原语时的性能。 如果你想加快速度,你可以通过切换到使用数组和while循环来获得最大的提升。 我不完全清楚你编写的代码甚至适用于IPv6,除了以IPv6格式存储的IPv4地址,因为你的子网可能超过256个。 此外,通过测试长度,您假设没有相同地址的混合IPv6 / IPv4表示。 我忘了整个“toInts”的东西,只是存储字节数组; 然后做一些事情(警告,未经测试) def contains(host: Host): Boolean = { //. ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)