我试图将导航菜单始终放在前面?如何让导航菜单位于我所有内容的顶部而不隐藏在它后面?
我的第二个问题是为什么当我点击导航菜单时,它有时会“闪烁”?
js
$(function() {
// Stick the #nav to the top of the window
var nav = $('#nav');
var navHomeY = nav.offset().top;
var isFixed = false;
var $w = $(window);
$w.scroll(function() {
var scrollTop = $w.scrollTop();
var shouldBeFixed = scrollTop > navHomeY;
if (shouldBeFixed && !isFixed) {
nav.css({
position: 'fixed',
top: 0,
left: nav.offset().left,
width: nav.width()
});
isFixed = true;
}
else if (!shouldBeFixed && isFixed)
{
nav.css({
position: 'static'
});
isFixed = false;
}
});
});
$(document).ready(function() { …Run Code Online (Sandbox Code Playgroud) 我有一个带有 hr 分隔符的网页,并尝试在我的 CSS 文件中为其添加颜色,但似乎没有任何修改起作用。有人可以帮忙吗。
这是我的 CSS 文件代码:
body {
background: linear-gradient(black,white);
text-align:center;
}
#main {
width: 1000;
height: 600px;
background: linear-gradient(gold, white);
margin: 25px auto;
border: solid 4px #FFFFFF;
}
h1 {
text-align: center;
font-family:"Times New Roman";
font-size: 40pt;
color: black;
}
hr{
height: 6px;
color: black;
}
Run Code Online (Sandbox Code Playgroud) 通常,打开模态框时,通过 HTML 调用该函数:
<button class="btn btn-lg btn-outline-primary" (click)="open(content)">Launch demo modal</button>
Run Code Online (Sandbox Code Playgroud)
这将打开模式:
<ng-template #content let-modal>
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">Profile update</h4>
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="dateOfBirth">Date of birth</label>
<div class="input-group">
<input id="dateOfBirth" class="form-control" placeholder="yyyy-mm-dd" name="dp" ngbDatepicker #dp="ngbDatepicker">
<div class="input-group-append">
<button class="btn btn-outline-secondary calendar" (click)="dp.toggle()" type="button"></button>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="modal.close('Save click')">Save</button>
</div>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
但是,由于情况(我正在使用 Google Charts 并且我可以使用的 HTML(click) = "open(content"没有暴露给我),我需要能够通过 …
javascript twitter-bootstrap typescript ng-bootstrap angular
我有两个数字,每个数字都包含from 1 to 6 digits. 我想使用 JavaScript 对它们进行比较,并根据它们的匹配情况给出一个百分比。
比较应该从左到右进行。
例子:
if 6D matching then 100% ==> Example: (value_1: 987456, value_2: 987456)
if 5D matching then 90% ==> Example: (value_1: 987450, value_2: 987456)
if 4D matching then 80% ==> Example: (value_1: 987400, value_2: 987456)
if 3D matching then 60% ==> Example: (value_1: 987000, value_2: 987456)
if 2D matching then 40% ==> Example: (value_1: 980000, value_2: 987456)
else 0% ==> Example: (value_1: 010101, value_2: 987456)
Run Code Online (Sandbox Code Playgroud)
我希望我很清楚。你能给我建议一个解决方案我怎样才能在函数中做到这一点?谢谢
我的页面上有一张图像,该图像从底部被咬掉。我有
html, body {
max-width: 100%;
overflow-x: hidden;
}
.image_button{
border-radius: 20px;
border: 5px solid #d3d3d3;
float: left;
margin-right:20px;
}
image-responsive is present in bootstrap.
text-center is in bootstrap
Run Code Online (Sandbox Code Playgroud)
在我的代码中,但这只是为了避免页面上的侧滚动。有什么方法可以避免侧滚动并且不从底部剪切图像?
<div id="gender" style="visibility: hidden ;" >
<h4 style="left: 20%; top: 10%;position: absolute; " class="text-center" ><b>Click on the female or male figure to select a gender.</b></h4>
<div style="left: 20%; top: 20%;position: absolute;" >
<img id="man" src="images/man.png" onClick="pg4('bh'); sess2('gender male');" class="img-responsive image_button">
<img id="woman" src="images/woman.png" onClick="pg4('bh'); sess2('gender female');" class="img-responsive image_button">
<h4 style="left: …Run Code Online (Sandbox Code Playgroud) 假设我有一个数组常量如下:
const people = [
{ first: 'John', last: 'Doe', year: 1991, month: 6 },
{ first: 'Jane', last: 'Doe', year: 1990, month: 9 },
{ first: 'Jahn', last: 'Deo', year: 1986, month: 1 },
{ first: 'Jone', last: 'Deo', year: 1992, month: 11 },
{ first: 'Jhan', last: 'Doe', year: 1989, month: 4 },
{ first: 'Jeon', last: 'Doe', year: 1992, month: 2 },
{ first: 'Janh', last: 'Edo', year: 1984, month: 7 },
{ first: 'Jean', last: 'Edo', …Run Code Online (Sandbox Code Playgroud) 我有2个对象数组
第一个叫做数据:
const data = [
{
id: 1,
nombre: 'Piero',
},
{
id: 4,
nombre: 'Nelson',
},
{
id: 7,
nombre: 'Diego'
},
]
Run Code Online (Sandbox Code Playgroud)
第二个叫做subs:
const subs = [
{
id: 1,
name: 'Temprano',
},
{
id: 4,
name: 'A tiempo',
},
{
id: 7,
name: 'Tarde'
},
]
Run Code Online (Sandbox Code Playgroud)
在这我想比较,如果它们具有相同的ID,该潜艇阵列将其名称值传递给它,如果它不匹配,它把一个" - "数据阵列中,试试这个方法:
data.forEach((d)=>{
subs.forEach((s)=>{
if(d.id === s.id){
d.subname = s.name;
}
else {
d.subname = '-';
}
});
});
Run Code Online (Sandbox Code Playgroud)
但总是分配值,'-'就好像它不匹配任何值.我做错了什么?还有其他更简单的方法吗?非常感谢你的帮助.
的大小潜艇阵列可以变化.
我想将搜索栏中的值显示为""的搜索结果.
这就是我到目前为止所做的,为什么这不起作用?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type="text" id="autocomplete" value="" placeholder="Search for names.." title="Type in a name">
<p>
Search results for "<span id="result"></span>"
</p>
<button onclick="myname();"> Button </button>
<script>
function myname () {
document.getElementById("autocomplete").value = document.getElementById("result").innerHTML;
}
</script>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
可能重复:
JavaScript拆分而不会丢失字符
我有一个字符串:
"<foo>abcdefg</bar><foo>abcdefg</bar><foo>abcdefg</bar><foo>abcdefg</bar>"
Run Code Online (Sandbox Code Playgroud)
我想将"abcdefg"的所有实例分成如下数组:
["<foo>abcdefg</bar>", "<foo>abcdefg</bar>", "<foo>abcdefg</bar>", "<foo>abcdefg</bar>"];
Run Code Online (Sandbox Code Playgroud)
我尝试:
var str="<foo>abcdefg</bar><foo>abcdefg</bar><foo>abcdefg</bar><foo>abcdefg</bar>";
var Array_Of_FooBars = str.split("</bar>");
alert(Array_Of_FooBars);
Run Code Online (Sandbox Code Playgroud)
但它返回:
["<foo>abcdefg", "<foo>abcdefg", "<foo>abcdefg", "<foo>abcdefg",]
Run Code Online (Sandbox Code Playgroud)
它正在删除分隔符''.我不希望这样.
如何使用拆分而不丢失字符串中的分隔符?
谢谢.肯
javascript ×7
html ×4
css ×3
arrays ×2
ecmascript-6 ×2
angular ×1
jquery ×1
ng-bootstrap ×1
split ×1
typescript ×1