【发布时间】:2017-01-08 22:50:26
【问题描述】:
我做了一个引导项目,导航栏的高度在屏幕宽度上是一致的:这太棒了。
这是一个新项目,我自己不知道该怎么做。我只使用引导程序中的网格系统 - 没有别的。
当我使用 chrome 检查器工具更改屏幕宽度时,需要一个固定的导航栏高度。我很难实现的东西——即使是在一个只有 index.html 和 style.css 的不同的更干净的文件中。
我在这个项目中首先使用移动设备,所以不要伤到你的眼睛,我正在使用 320 像素的视口。*
Fiddle: https://jsfiddle.net/m9b9zba3/
HTML 和 CSS:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Band Index Page</title>
<link href="css/reset.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap-grid-only.min.css" rel="stylesheet" type="text/css">
<link href="css/main.css" rel="stylesheet" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Oswald:300,400,700" rel="stylesheet">
</head>
<body>
<header>
<div class="band-hero col-xs-12">
<div class="band-member-grid"><img src="../img/placeholder-sm.jpg" class="img-responsive">
<div class="img-overlay content">
<div class="member">
<div class="name"> </div>
<div class="role"></div>
</div>
<div class="member">
<div class="name"></div>
<div class="role"></div>
</div>
<div class="member">
<div class="name"></div>
<div class="role"></div>
</div>
<div class="member">
<div class="name"></div>
<div class="role"></div>
</div>
<div class="member">
<div class="name"></div>
<div class="role"></div>
</div>
</div>
</div>
</div>
</header>
<section class="col-sm-12">
<div class="upcmoing-gigs content">
<div class="row">
<article class="up-gig col-xs-4">
<h4>date</h4>
<h7>where</h7>
<p>some details</p>
</article>
<article class="up-gig col-xs-4">
<h4>date1</h4>
<h7>where</h7>
<p>some details</p>
</article>
<article class="up-gig col-xs-4">
<h4>date2</h4>
<h7>where</h7>
<p>some details</p>
</article>
</div>
<div class="row">
<article class="up-gig col-xs-4">
<h4>date3</h4>
<h7>where</h7>
<p>some details</p>
</article>
<article class="up-gig col-xs-4">
<h4>date4</h4>
<h7>where</h7>
<p>some details</p>
</article>
<article class="up-gig col-xs-4">
<h4>date5</h4>
<h7>where</h7>
<p>some details</p>
</article>
</div>
</div>
</section>
<section>
<div class="logo"></div>
<div class="blog-news col-xs-12">
<h2 class="content">Latest news...</h2>
<article></article>
</div>
</section>
<footer>
<nav class="navbar col-xs-12 row">
<input type="checkbox"><span class="arrow-up col-xs-2"></span>
<div class="content logo col-xs-2">Logo</div>
<ul class="nav-right col-xs-12">
<li class="nav-item content"><a>4</a></li>
<li class="nav-item content"><a>Contact</a></li>
<li class="nav-item content"><a>About</a></li>
<li class="nav-item content"><a>Home</a></li>
</ul>
</nav>
</footer>
</body>
</html>
CSS:
html {
margin: 0;
padding: 0;
height: 100%
}
body {
margin: 0;
position: relative;
height: 100%;
font-size: 18px;
font-family: 'Oswald', sans-serif;
font-weight: 100
}
input {
padding: 0;
margin: 0
}
img {
display: block;
padding: 0;
margin: 0
}
.content {
font-size: 3em
}
.row {
margin: 0;
padding: 0
}
img.img-responsive {
width: 100%;
height: auto
}
.up-gig {
box-sizing: border-box;
padding: 1%;
border: 2px solid #000
}
.navbar {
display: block;
overflow: hidden;
list-style-type: none;
position: fixed;
bottom: 0;
background: #545454;
list-style: none
}
.navbar .logo {
width: 180px;
height: 120px
}
.arrow-up {
width: 0;
height: 0;
border-left: 45px solid transparent;
border-right: 45px solid transparent;
border-bottom: 45px solid #000;
margin: 3% 4% 0;
z-index: 1;
float: right
}
.navbar li {
height: 120px;
border-radius: 5px;
border-sizing: border-box;
position: relative
}
.navbar li:nth-child(odd) {
background: #828282
}
.navbar ul li a {
display: inline-block;
margin: 34px
}
.navbar input[type=checkbox] {
background-color: #800080;
opacity: 0;
width: 150px;
height: 120px;
position: absolute;
right: 2%;
z-index: 3
}
.nav-item {
margin: auto 0;
width: 100%;
text-align: center;
font-weight: 300
}
.navbar input {
float: right
}
.nav-left {
float: left
}
.nav-right {
float: right
}
.navbar input[type=checkbox] ~ ul {
height: 0;
-webkit-transition: height .3s linear;
transition: height .3s linear
}
.navbar input[type=checkbox]:checked ~ ul {
height: 480px;
-webkit-transition: height .3s ease-in-out;
transition: height .3s ease-in-out
}
.navbar input[type=checkbox] ~ span {
-webkit-transition: -webkit-transform .3s ease-in-out;
transition: -webkit-transform .3s ease-in-out;
transition: transform .3s ease-in-out;
transition: transform .3s ease-in-out, -webkit-transform .3s ease-in-out
}
.navbar input[type=checkbox]:checked ~ span {
margin-top: 4.3%;
-webkit-transform: rotate(-180deg);
transform: rotate(-180deg);
-webkit-transition: -webkit-transform .3s linear;
transition: -webkit-transform .3s linear;
transition: transform .3s linear;
transition: transform .3s linear, -webkit-transform .3s linear
}
附:我还使用复选框 hack 在较小的屏幕上切换导航栏。 我不能真正让网站按我想要的那样扩展,但是,我稍后会探索。 提前谢谢:)
【问题讨论】:
-
我很困惑。我看到一个固定的左侧导航栏;期待一个顶级酒吧。您希望左侧导航栏具有固定高度吗?
-
到底是什么问题?请描述当前状态和期望的状态
-
嗨,问题是当我使用 chrome 检查器工具时,导航栏是响应式的。当我使用 chrome 检查器更改窗口的宽度时,我希望它保持在固定的高度。我仍在尝试一个干净的文件,但没有成功。
标签: html css twitter-bootstrap