[英]Transparent nav-bar
I have the following issue: 我有以下问题:
position:absolute
to it 我删除了背景并应用了position:absolute
Information: The image blow shows the design after position:absolute
. 信息:图像打击显示position:absolute
后的设计。 The attached sample code is showing the original design before I applied changes to make it transparent. 所附的示例代码显示了在应用更改使其透明之前的原始设计。
Problem: After I applied position:absolute
to navbar the items moved from right to left. 问题:在对导航栏应用position:absolute
之后,项目从右移到左。
Goal: Just to make the goal clear: I want same navbar just with transparent background. 目标:只是为了明确目标:我想要具有透明背景的相同导航栏。
* { box-sizing: border-box; margin: 0; padding: 0; } .row { clear: both; } .spalten-6 { width: 49.99992%; } .spalten-12 { width: 100%; } .spalten-6, .spalten-12 { float: left; } .img-box img { width: 100%; } .img-box { border-left: 2px solid white; border-top: 2px solid white; } #video-container { position: relative; height: 300px } #video-container { top: 0%; left: 0%; height: 100%; width: 100%; overflow: hidden; } video#bgVid { position: absolute; z-index: -1; background: url('http://ewallpaperhub.com/wp-content/uploads/2015/01/nature-wallpaper-3.jpg') no-repeat; background-size: cover; transition: 1s opacity; } video#bgVid.fillWidth { width: 100%; position: relative } nav { background-color: black; margin: 0; overflow: hidden; } nav ul { margin: 0; padding: 0; } nav ul li { list-style-type: none; } nav ul li a { color: white; background-color: black; display: block; line-height: 1em; padding: 1em 1.5em; text-decoration: none; letter-spacing: 0.15em; font-size: 13px; } nav ul li a.logo { background-color: black; } nav ul li a:hover { background-color: ; } li { float: right; } li:first-child { float: left; } nav ul li a img { width: 16px; height: 16px; float: right; margin-left: -20px; } .logo { font-size: 20px; letter-spacing: 0.1em; } .abstand-top { margin-top: 10px; } } nav ul li a img { width: 16px; height: 16px; float: right; margin-left: -20px; } .logo { font-size: 20px; letter-spacing: 0.1em; } .abstand-top { margin-top: 10px; }
<nav> <ul> <li><a href="http://google.com/" class="logo">BOOMYEAH</a></li> <li class="abstand-top"> <a href="#"><img src="Images/icon-facebook.svg" alt=""></a> </li> <li class="abstand-top"> <a href="#"><img src="Images/icon-instagram.svg" alt=""></a> </li> <li class="abstand-top"><a href="http://google.com/">WORK |</a></li> <li class="abstand-top"><a href="http://google.com/">ABOUT</a></li> <li class="abstand-top"><a href="http://google.com/">CREW</a></li> <li class="abstand-top"><a href="http://google.com/">CONTACT</a></li> </ul> </nav> <div id="video-container"> <video id="bgVid" loop class="fillWidth" autoplay> <source src=http://bigcom.com/assets/2014/08/iChooseB.mp4 type=video/mp4> </video> </div>
Hope we will find a solution. 希望我们能找到解决方案。
nav
to absolute 您没有将nav
的位置设置为绝对 z-index
to make sure it has higher z-index
so the user can click on the items in the menu. 您需要设置z-index
以确保其具有较高的z-index
以便用户可以单击菜单中的项目。 * { box-sizing: border-box; margin: 0; padding: 0; } .row { clear: both; } .spalten-6 { width: 49.99992%; } .spalten-12 { width: 100%; } .spalten-6, .spalten-12 { float:left;} .img-box img { width: 100%; } .img-box { border-left: 2px solid white; border-top: 2px solid white; } #video-container { position: relative; height:300px } #video-container { top:0%; left:0%; height:100%; width:100%; overflow: hidden; } video#bgVid { position:absolute; z-index:-1; background: url('http://ewallpaperhub.com/wp-content/uploads/2015/01/nature-wallpaper-3.jpg') no-repeat; background-size: cover; transition: 1s opacity; } video#bgVid.fillWidth { width: 100%; position:relative } nav { margin: 0; overflow: hidden; position: absolute; z-index: 10; } nav ul { margin: 0; padding: 0; } nav ul li { list-style-type: none; } nav ul li a { color: white; display: block; line-height: 1em; padding: 1em 1.5em; text-decoration: none; letter-spacing: 0.15em; font-size: 13px; } nav ul li a.logo { background-color: black; } nav ul li a:hover { background-color: ; } li { float: right; } li:first-child { float: left; } nav ul li a img { width: 16px; height: 16px; float: right; margin-left: -20px; } .logo { font-size: 20px; letter-spacing: 0.1em; } .abstand-top { margin-top: 10px; } } nav ul li a img { width: 16px; height: 16px; float: right; margin-left: -20px; } .logo { font-size: 20px; letter-spacing: 0.1em; } .abstand-top { margin-top: 10px; }
<nav> <ul> <li><a href="http://google.com/" class="logo">BOOMYEAH</a></li> <li class="abstand-top"><a href="#"><img src="Images/icon-facebook.svg" alt=""></a></li> <li class="abstand-top"><a href="#"><img src="Images/icon-instagram.svg" alt=""></a></li> <li class="abstand-top"><a href="http://google.com/">WORK |</a></li> <li class="abstand-top"><a href="http://google.com/">ABOUT</a></li> <li class="abstand-top"><a href="http://google.com/">CREW</a></li> <li class="abstand-top"><a href="http://google.com/">CONTACT</a></li> </ul> </nav> <div id="video-container"> <video id="bgVid" loop class="fillWidth" autoplay> <source src=http://bigcom.com/assets/2014/08/iChooseB.mp4 type=video/mp4> </video> </div>
You need to use the background-color: rgba()
property for the nav bar. 您需要为导航栏使用background-color: rgba()
属性。 rgba()
is a function which takes 4 parameters, first three are the color values of RED, GREEN and BLUE, and the 4th parameter is transparency of the background, which can vary from 0 to 1. So, after adding it your code should look like: rgba()
是一个具有4个参数的函数,前三个是RED,GREEN和BLUE的颜色值,第4个参数是背景的透明度,其范围可以从0到1。因此,在添加之后,您的代码应该看起来像:
* { box-sizing: border-box; margin: 0; padding: 0; } .row { clear: both; } .spalten-6 { width: 49.99992%; } .spalten-12 { width: 100%; } .spalten-6, .spalten-12 { float:left;} .img-box img { width: 100%; } .img-box { border-left: 2px solid white; border-top: 2px solid white; } #video-container { position: relative; height:300px } #video-container { top:0%; left:0%; height:100%; width:100%; overflow: hidden; } video#bgVid { position:absolute; z-index:-1; background: url('http://ewallpaperhub.com/wp-content/uploads/2015/01/nature-wallpaper-3.jpg') no-repeat; background-size: cover; transition: 1s opacity; } video#bgVid.fillWidth { width: 100%; position:relative } nav { margin: 0; overflow: hidden; position: absolute; background-color: rgba(0,0,0,0.8); z-index: 10; } nav ul { margin: 0; padding: 0; } nav ul li { list-style-type: none; } nav ul li a { color: white; display: block; line-height: 1em; padding: 1em 1.5em; text-decoration: none; letter-spacing: 0.15em; font-size: 13px; } nav ul li a.logo { background-color: black; } nav ul li a:hover { background-color: ; } li { float: right; } li:first-child { float: left; } nav ul li a img { width: 16px; height: 16px; float: right; margin-left: -20px; } .logo { font-size: 20px; letter-spacing: 0.1em; } .abstand-top { margin-top: 10px; } } nav ul li a img { width: 16px; height: 16px; float: right; margin-left: -20px; } .logo { font-size: 20px; letter-spacing: 0.1em; } .abstand-top { margin-top: 10px; }
<nav> <ul> <li><a href="http://google.com/" class="logo">BOOMYEAH</a></li> <li class="abstand-top"><a href="#"><img src="Images/icon-facebook.svg" alt=""></a></li> <li class="abstand-top"><a href="#"><img src="Images/icon-instagram.svg" alt=""></a></li> <li class="abstand-top"><a href="http://google.com/">WORK |</a></li> <li class="abstand-top"><a href="http://google.com/">ABOUT</a></li> <li class="abstand-top"><a href="http://google.com/">CREW</a></li> <li class="abstand-top"><a href="http://google.com/">CONTACT</a></li> </ul> </nav> <div id="video-container"> <video id="bgVid" loop class="fillWidth" autoplay> <source src=http://bigcom.com/assets/2014/08/iChooseB.mp4 type=video/mp4> </video> </div>
You can change the 4th value in the rgba() function as you want, i set it to 0.8. 您可以根据需要在rgba()函数中更改第4个值,我将其设置为0.8。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.