CSS 为什么我的 Bootstrap 代码不起作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12649246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:18:41  来源:igfitidea点击:

Why is my Bootstrap code not working?

csstwitter-bootstrapstylesheet

提问by Tom Maxwell

Tonight I decided to give Bootstrap a try (only been doing CSS/HTML for about two weeks), but I'm running into a problem. For whatever reason, it doesn't seem like my HTML doc is linking to the Bootstrap stylesheet. I used one of their dropdown code snippets, but the end result isn't stylized. Can someone see if I'm doing something wrong? Below is my HTML code.

今晚我决定尝试一下 Bootstrap(只做了大约两周的 CSS/HTML),但我遇到了一个问题。无论出于何种原因,我的 HTML 文档似乎都没有链接到 Bootstrap 样式表。我使用了他们的下拉代码片段之一,但最终结果没有风格化。有人可以看看我是否做错了什么吗?下面是我的 HTML 代码。

<!DOCTYPE html>


<html lang = "en">

<head>
<title>Test</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />

</head>
<body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>

<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
<li><a tabindex="-1" href="#">Action</a></li>
<li><a tabindex="-1" href="#">Another action</a></li>
<li><a tabindex="-1" href="#">Something else here</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#">Separated link</a></li>
</ul>

</body>
</html>

回答by Simon

Are all the files in the right folders? You are using relative url:s, can be confusing if you just started to code. How is your folder structure? Are the index.html and the css folder in the same directory?

所有文件都在正确的文件夹中吗?您使用的是相对 url:s,如果您刚开始编码,可能会感到困惑。你的文件夹结构如何?index.html 和 css 文件夹在同一个目录下吗?

回答by defau1t

You Need to look at the file structure of how bootstrap files are added:

您需要查看如何添加引导程序文件的文件结构:

http://twitter.github.com/bootstrap/getting-started.html#file-structure

http://twitter.github.com/bootstrap/getting-started.html#file-structure

回答by myflytop

try add "style="display: block; position: static; margin-bottom: 5px; *width: 180px"

尝试添加“样式=”显示:块;位置:静态;底边距:5px;*宽度:180px”

<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display: block; position: static; margin-bottom: 5px; *width: 180px;">
            <li><a tabindex="-1" href="#">Action</a></li>
            <li><a tabindex="-1" href="#">Another action</a></li>
            <li><a tabindex="-1" href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a tabindex="-1" href="#">Separated link</a></li>
          </ul>