我试图复制这个网站,作为引导学习课程的一部分。
(
https://trickyicky84.000webhostapp.com/
)HTML中有nav后跟一个section元素(带有类intro),并且有一个应用于section元素的背景图像。
您可以看到,导航的背景在视野中为深色<768但变得透明>768和应用于的背景图像。介绍部分似乎在导航中显示出来。我不知道是哪种代码使导航透明,更重要的是,背景图像如何应用于一个部分,应用于导航元素。
我假设是这样的:
@media(min-width:767px) {
.navbar {
padding: 20px 0;
border-bottom: none;
letter-spacing: 1px;
background: transparent;
-webkit-transition: background .5s ease-in-out,padding .5s ease-in-out;
-moz-transition: background .5s ease-in-out,padding .5s ease-in-out;
transition: background .5s ease-in-out,padding .5s ease-in-out;
}
我在自己的版本中也尝试过类似的代码(使背景:对导航栏透明),但它似乎采用了Bootstrap中的background:0样式,给它一种类似灰色的颜色。我还没有研究CSS转换,我不确定这是否是使用原始站点中的转换来完成的。我的网站在
https://trickyicky83.000webhostapp.com/
.
正在运行的版本的完整CSS:
@import "vendors/bootstrap/bootstrap.less";
@import "vendors/font-awesome/font-awesome.less";
@primary: #26a5d3;
@dark: #333333;
@light: #f4f4f4;
html{
width:100%;
height:100%;
}
body{
width:100%;
height:100%;
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
color:@dark;
background-color:@light;
}
// Typography
h1, h2, h3, h4, h5, h6{
margin: 0 0 35px;
text-transform:uppercase;
font-family: "Montserrat","Helvetica Neue",Helvetica,Arial,sans-serif;
letter-spacing:1px;
}
p{
margin: 0 0 25px;
font-size:18px;
line-height:1.6em;
}
a{
color:@primary;
}
a:hover,a:focus{
text-decoration:none;
color: darken(@primary, 20%);
}
// Navigation
.navbar {
margin-bottom: 0;
border-bottom: 1px solid rgba(255,255,255,0.3);
text-transform: uppercase;
font-family: "Montserrat","Helvetica Neue",Helvetica,Arial,sans-serif;
background-color: @dark;
}
.navbar-brand {
font-weight: 700;
}
.navbar-brand:focus {
outline: none;
}
.navbar-custom a {
color: @light;
}
.navbar-custom .nav li a {
-webkit-transition: background .3s ease-in-out;
-moz-transition: background .3s ease-in-out;
transition: background .3s ease-in-out;
}
.navbar-custom .nav li a:hover,
.navbar-custom .nav li a:focus,
.navbar-custom .nav li.active {
outline: none;
background-color: rgba(255,255,255,0.2);
}
.navbar-toggle {
padding: 4px 6px;
font-size: 16px;
color: @light;
}
.navbar-toggle:focus,
.navbar-toggle:active {
outline: none;
}
@media(min-width:767px) {
.navbar {
padding: 20px 0;
border-bottom: none;
letter-spacing: 1px;
background: transparent;
-webkit-transition: background .5s ease-in-out,padding .5s ease-in-out;
-moz-transition: background .5s ease-in-out,padding .5s ease-in-out;
transition: background .5s ease-in-out,padding .5s ease-in-out;
}
.top-nav-collapse {
padding: 0;
background-color: @dark;
}
.navbar-custom.top-nav-collapse {
border-bottom: 1px solid rgba(255,255,255,0.3);
}
}
// Landing Page
.intro{
display:table;
width:100%;
height:auto;
padding:100px 0;
text-align:center;
color:@light;
background: url(../img/intro-bg.jpg) no-repeat bottom center scroll;
background-color:@dark;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.intro-body{
display:table-cell;
vertical-align:middle;
}
.brand-heading{
font-size:40px;
}
.intro-text{
font-size:18px;
}
@media(min-width:767px) {
.intro{
height:100%;
padding:0;
}
.brand-heading{
font-size:100px !important;
}
.intro-text{
font-size:25px;
}
}
这是我的版本,不起作用:
@import "vendor/bootstrap/bootstrap.less";
@import "vendor/font-awesome/font-awesome.less";
@primary: #26a5d3;
@dark: #333333;
@light: #f4f4f4;
body {
margin-top:50px;
background-color: @light;
color:@dark;
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
}
// typography
h1,h2,h3,h4,h5,h6 {
text-transform:uppercase;
margin:0 0 30px;
letter-spacing:1px;
}
p {
margin: 0 0 25px;
font-size:18px;
line-height:1.6em;
}
// Navigation
.navbar {
margin-bottom: 0;
border-bottom: 1px solid rgba(255,255,255,0.3);
text-transform: uppercase;
font-family: "Montserrat","Helvetica Neue",Helvetica,Arial,sans-serif;
background-color:@dark;
}
.navbar .navbar-brand {
font-weight:700;
color:@light;
}
.navbar .nav li a {
color:@light;
}
.navbar .nav li a:hover {
color:@light;
}
.navbar .nav li a {
-webkit-transition: background .3s ease-in-out;
-moz-transition: background .3s ease-in-out;
transition: background .3s ease-in-out;
}
.navbar .nav li a:hover,
.navbar .nav li a:focus,
.navbar .nav li.active {
outline: none;
background-color: rgba(255,255,255,0);
}
@media(min-width:768px) {
.navbar {
padding:20px 0 ;
letter-spacing:1px;
background: transparent;
-webkit-transition: background .5s ease-in-out,padding .5s ease-in-out;
-moz-transition: background .5s ease-in-out,padding .5s ease-in-out;
transition: background .5s ease-in-out,padding .5s ease-in-out;
}
}
//intro
.intro {
display:table;
padding:100px 0;
width:100%;
color:@light;
background: url(../img/intro-bg.jpg) no-repeat bottom center;
background-color:@dark;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.intro-body {
display:table-cell;
vertical-align:middle;
}
.intro h1 {
font-size:40px;
}
.intro p {
font-size:18px;
}
@media(min-width:767px) {
.intro h1 {
font-size:100px !important;
}
.intro p {
font-size:25px;
}
}