问题描述
我正在尝试创建一个网页,其中包含一个标题和一个项目列表。我希望项目列表可以垂直滚动。我也希望网页能够占据整个窗口,但不会更大。目前我的问题是项目列表不可滚动,而是延伸到远低于窗口底部,这导致窗口滚动。 , ,标题和列表项目?
doctype html
html
头部
link(href =css / style .cssrel =stylesheet)
body $ b $ div div wrapper
h1 Interactive Contact Directory $ b $ div div class
input(type =textid =searchBox)
select(name =searchByid =searchBy)
option(value ='firstname')First名称
选项(值='姓氏')姓氏
选项(值='email')电子邮件
br
br
div(id =listingHolder)
ul(id =listing)
div(id =listingView)
Bellow是我现有的样式表
html {
高度:100%;
}
body {
background:#121212;
margin:0px;
padding:0px;
font-family:Open Sans,sans-serif;
身高:100%;
}
#wrapper {
最大高度:100%;
}
h1 {
margin:0px;
颜色:#fff;
padding:20px;
text-align:center;
font-weight:100;
}
.tools {
text-align:center;
颜色:#fff;
}
#searchBox {
padding:7px;
border:none;
border-radius:5px;
font-size:1.2em;
}
a.filter {
display:inline-block;
padding:5px 10px;
margin:5px;
背景:#0472C0;
颜色:#fff;
text-decoration:none;
border-radius:3px;
}
a.filter:hover {
background:#0B9DE0;
颜色:#fff;
}
ul#列表{
list-style:none;
padding:0px;
margin:0px;
背景:#fff;
宽度:100%;
}
ul#列表li {
list-style:none;
border-bottom:1px solid #eee;
display:block;
}
ul#列出li .list-header {
padding:10px;
光标:指针;
display:block;
}
ul#列出li .list-header:hover {
background:#7893AB;
颜色:#fff;
}
ul#列出li .list-header.active {
背景:#447BAB;
颜色:#fff;
}
ul#列出li .details {
display:none;
背景:#efefef;
padding:20px;
font-size:0.9em;
}
#listingHolder {
width:50%;
overflow:scroll;
具有滚动条效果。
CSS / HTML:
nav ul {height:200px; width:18%;} nav ul {overflow:hidden; overflow-y:scroll;}
<!DOCTYPE html> ;< HTML> < HEAD> < meta charset =utf-8> < title> JS Bin< / title> < /头> <身体GT; <标题>标题区< /标题> < NAV> < UL> < li>连结1< / li> < li>连结2< / li> < li>连结3< / li> < li>连结4< / li> < li>连结5< / li> < li>连结6< / li> < li>连结7< / li> < li>连结8< / li> < li>连结9< / li> < li>连结10< / li> < li>连结11< / li> < li>连结13< / li> < li>连结13< / li> < / UL> < / NAV> < footer> footer area< / footer> < / body>< / html>
I am trying to create a webpage which is made up of a header and bellow the header a list of items. I want the list of items to be vertically scrollable. I also would like the webpage to take up the entire window but not be bigger. Currently my problem is the list of items is not scrollable and instead extends far below the bottom of the window and this is causing the window to be scrollable. What should the CSS properties be on the html, body, header and list items?
doctype html
html
head
link(href="css/style.css" rel="stylesheet")
body
div#wrapper
h1 Interactive Contact Directory
div(class="tools")
|Search:
br
input(type="text" id="searchBox")
select(name="searchBy" id="searchBy")
option(value='firstname') First Name
option(value='lastname') Last Name
option(value='email') Email
br
br
div(id="listingHolder")
ul(id="listing")
div(id="listingView")
Bellow is the current style sheet I have
html{
height: 100%;
}
body {
background:#121212;
margin:0px;
padding:0px;
font-family:"Open Sans", sans-serif;
height: 100%;
}
#wrapper {
max-height: 100%;
}
h1 {
margin:0px;
color:#fff;
padding:20px;
text-align:center;
font-weight:100;
}
.tools {
text-align:center;
color:#fff;
}
#searchBox {
padding:7px;
border:none;
border-radius:5px;
font-size:1.2em;
}
a.filter {
display:inline-block;
padding:5px 10px;
margin:5px;
background:#0472C0;
color:#fff;
text-decoration:none;
border-radius:3px;
}
a.filter:hover {
background:#0B9DE0;
color:#fff;
}
ul#listing {
list-style:none;
padding:0px;
margin:0px;
background:#fff;
width:100%;
}
ul#listing li {
list-style:none;
border-bottom:1px solid #eee;
display:block;
}
ul#listing li .list-header {
padding:10px;
cursor:pointer;
display:block;
}
ul#listing li .list-header:hover {
background:#7893AB;
color:#fff;
}
ul#listing li .list-header.active {
background:#447BAB;
color:#fff;
}
ul#listing li .details {
display:none;
background:#efefef;
padding:20px;
font-size:0.9em;
}
#listingHolder{
width: 50%;
overflow: scroll;
}
As per your question vertical listing have a scrollbar effect.
CSS / HTML :
nav ul{height:200px; width:18%;}
nav ul{overflow:hidden; overflow-y:scroll;}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<header>header area</header>
<nav>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
<li>Link 6</li>
<li>Link 7</li>
<li>Link 8</li>
<li>Link 9</li>
<li>Link 10</li>
<li>Link 11</li>
<li>Link 13</li>
<li>Link 13</li>
</ul>
</nav>
<footer>footer area</footer>
</body>
</html>
这篇关于CSS如何制作可滚动列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!