使用 Bootstrap 禁用边栏滚动
Disable Scrolling on Sidebar Using Bootstrap
我是 Bootstrap 的新手,需要帮助解决两个问题:
首先,如何禁用边栏上的滚动?我希望左栏固定在屏幕上,而不是随着右侧的内容滚动。
最后,我如何move/push 将边栏上的内容显示在浏览器的最边缘window?我也希望第二列向左移动。
这是我的代码:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CodeButler</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12 sidebar">
<h1>Title of Webpage</h1>
<p>Some text will go here.</p>
<ul>
<li><a href="index.html" alt="Home">Home</a></li>
<li><a href="about.html" alt="About">About</a></li>
<li><a href="archives.html" alt="Archives">Archives</a></li>
</ul>
</div>
<div class="col-lg-4 col-md-8 col-sm-6 col-xs-12 articles">
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
</div>
</div>
</div>
</body>
</html>
谢谢!
要修复侧边栏,您只需添加一些 css 即可。
.sidebar {
position: fixed;
top: 0;
bottom: 0;
left: 0;
}
看看你是否正在寻找以下内容:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CodeButler</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-4 sidebar">
<h1>Title of Webpage</h1>
<p>Some text will go here.</p>
<ul>
<li><a href="index.html" alt="Home">Home</a></li>
<li><a href="about.html" alt="About">About</a></li>
<li><a href="archives.html" alt="Archives">Archives</a></li>
</ul>
</div>
<div class="col-lg-8 articles">
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
</div>
</div>
</div>
</body>
</html>
我是 Bootstrap 的新手,需要帮助解决两个问题:
首先,如何禁用边栏上的滚动?我希望左栏固定在屏幕上,而不是随着右侧的内容滚动。
最后,我如何move/push 将边栏上的内容显示在浏览器的最边缘window?我也希望第二列向左移动。
这是我的代码:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CodeButler</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12 sidebar">
<h1>Title of Webpage</h1>
<p>Some text will go here.</p>
<ul>
<li><a href="index.html" alt="Home">Home</a></li>
<li><a href="about.html" alt="About">About</a></li>
<li><a href="archives.html" alt="Archives">Archives</a></li>
</ul>
</div>
<div class="col-lg-4 col-md-8 col-sm-6 col-xs-12 articles">
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
</div>
</div>
</div>
</body>
</html>
谢谢!
要修复侧边栏,您只需添加一些 css 即可。
.sidebar {
position: fixed;
top: 0;
bottom: 0;
left: 0;
}
看看你是否正在寻找以下内容:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CodeButler</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-4 sidebar">
<h1>Title of Webpage</h1>
<p>Some text will go here.</p>
<ul>
<li><a href="index.html" alt="Home">Home</a></li>
<li><a href="about.html" alt="About">About</a></li>
<li><a href="archives.html" alt="Archives">Archives</a></li>
</ul>
</div>
<div class="col-lg-8 articles">
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
<h6>Date Here</h6>
<h3>Title Here</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed mi a purus euismod dapibus at eu ante. Nunc erat risus, laoreet at elementum id, dignissim at quam. In accumsan sem a lectus vulputate, eget condimentum odio condimentum. Nulla facilisi. Duis enim dolor, tristique eu finibus sit amet, molestie vel metus. Sed a ultricies urna. Duis eget lectus vitae ligula accumsan feugiat at ut libero.</p>
</div>
</div>
</div>
</body>
</html>