我之前没有使用任何引导框架.我想在我的页面上包含bootstrap 3中的一些glyphicons.根据我的理解,他们应该包含在我已添加到我的页面的bootstrap.css文件中.当我查看bootstrap.css文件但是我没有看到任何对它们的引用?虽然它是一个大文件,但我可能错过了一些东西.
我注意到当我打开dist从bootstrap 3下载的 文件夹时,有一个单独的文件夹fonts,其中包含名为的文件:
glyphicons-halflings-regular.eot
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff
Run Code Online (Sandbox Code Playgroud)
看起来像这是glyphicons但我不知道如何将这些附加到我的网站?如何将字形附加到我的页面?
在此先感谢您的帮助
下面的代码显示了附加的bootstrap.css文件:
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap example</title>
<meta name="viewport" content="width=divice-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="bootstrap.css" rel="stylesheet" media="screen">
</head>
Run Code Online (Sandbox Code Playgroud)
这是html代码的一部分,显示了glyphicons应该在哪里:
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span>
Home</a></li>
<li><a href="#"><span class="glyphicon glyphicon-star"></span> Top
Destinations</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span
class="glyphicon glyphicon-user"></span> About Us<b class="caret"></b></a>
Run Code Online (Sandbox Code Playgroud) 我有一个段落元素数组。当每个<p>元素被点击时,我希望该元素从 DOM 中删除。我编写的代码仅在元素由其 id 指定时才有效。我尝试使用this关键字,并循环遍历元素,但没有成功,如下面的代码所示。
我在这里做错了什么?我怎样才能克服它?
<div class="section" id='section2'>
<a name="section-two" href="#top">Section Two</a>
<p id='tester'>Text here <span><img src='images/remove.png' height='20px'/></span></p>
<p>Text here. <span><img src='images/remove.png' width='20px'/></span></p>
<p>Text here. <span><img src='images/remove.png' height='20px'/></span></p>
<p>Text here. <span><img src='images/remove.png' height='20px'/></span></p>
</div>
var section2 = document.getElementById('section2').getElementsByTagName('p');
for(var i = 0; i < section2.length; i++) {
section2[i].addEventListener('click', function() {
section2[i].parentNode.removeChild(section2[i]);
}, false);
}
Run Code Online (Sandbox Code Playgroud) 我有三个div具有相同类名的s,我想改变使用JavaScript的高度和颜色.我的代码坏了,不知道为什么.我在这里查看了类似问题的答案,我的代码似乎与解决方案相同.
我知道我的代码在哪里破解以及如何修复它?
<HTML>
<head></head>
<body>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<script>
function altSize() {
var bar = document.getElementsByClassName("bar");
bar.style.height = 200px;
bar.style.background = 'red';
}
altSize();
</script>
</body>
</HTML>
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个遍历对象属性的函数,如果该值是一个数字,则将值乘以2.
我确定它var value是一个整数但它不应用乘法?我在这个代码中哪里出错了?
var menu = {
width: "200",
height: "300",
title: "My menu"
};
function multiplyNumeric(menu) {
for(var key in menu) {
var value = menu[key];
if( typeof value === 'number' ) {
value = value * 2;
}
}
}
multiplyNumeric(menu);
alert(menu.width);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用javascript添加div.div出现在代码和chromes开发人员工具中,但没有显示在实际窗口中?
为什么会发生这种情况,我该如何纠正?
码:
<div id='body'>
<div id='inner'>div here</div>
</div>
<script>
function add() {
var inner = document.getElementById('inner');
var div = document.createElement('div');
div.style.height = '300px';
div.style.width = '100px';
div.style.color = 'blue';
inner.appendChild(div);
}
add();
</script>
Run Code Online (Sandbox Code Playgroud) 我创建了一个返回字符串最长字的函数.为了实现这一点,字符串已被拆分为一个数组并使用a进行迭代for loop.
出于某种原因,for循环在增加计数之前在同一项上迭代3次?我没有看到明显的错误.
这里发生了什么,我该如何阻止它?还有更好的方法来实现我在这里尝试做的事情吗?我对javascript比较陌生.
function longWord(str) {
var wordArr = str.split(' ');
var highest = 0;
var longestWd ;
for(var i = 0; i < wordArr.length; i++) {
var temp = wordArr[i].length
var word = wordArr[i];
if(temp > highest) {
highest = temp;
longestWd = word;
}
alert(longestWd);
alert(highest);
}
}
longWord('this is a string with a longest word');
Run Code Online (Sandbox Code Playgroud) javascript ×5
css ×2
for-loop ×2
html ×2
arrays ×1
directory ×1
for-in-loop ×1
function ×1
object ×1
removechild ×1