- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于一个项目,我需要每 7 秒滚动一次页面,如果到达底部,它会向上滚动。一遍又一遍。
到目前为止,我已经做到了每 7 秒向下滚动一次。我尝试了大约 20 个选项来滚动到顶部(如果它触及底部),但没有一个起作用。
我的代码:
<head><link href="http://fonts.googleapis.com/css?family=Hind:300,400,500,600,700" rel="stylesheet" type="text/css"><link href="vendor/simple-line-icons/css/simple-line-icons.css" rel="stylesheet" type="text/css"/><link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/><link href="css/animate.css" rel="stylesheet"><link href="vendor/swiper/css/swiper.min.css" rel="stylesheet" type="text/css"/>
<link href="vendor/magnific-popup/magnific-popup.css" rel="stylesheet" type="text/css"/>
<link href="css/layout.min.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" href="roostersb.png"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link href="css/custom.css" rel="stylesheet" type="text/css"/>
<style>
.klok{
position: fixed;
color: white;
right: 18%;
top: 7%;
}
h2.klok{
position: fixed;
color: white;
right: 2%;
text-transform: capitalize;
top: 0,5%;
}
.timer{
bottom: 2%;
right: 2%;
position: fixed;
color: black;
}
.tr{
font-size: 150%;
}
h1.kaaart{
color: white;
font-weight: bold;
top: 11%;
right: 2%;
}
.kaaart{
background-color: #f2f2f2;
/*-webkit-border-radius: 10px;*/
/*-moz-border-radius: 10px;*/
/*border-radius: 10px;*/
box-shadow: 0 0 17px #414243;
-webkit-box-shadow: 0 0 17px #414243;
-moz-box-shadow: 0 0 17px #414243;
text-align: center;
/*horizontal-align: middle;*/
text-transform: capitalize;
}
.mijntafel{
font-size: 160%;
}
.mijntafeltop{
font-size: 180%;
}
th.mijntafeltop{
font-size: 170%;
}
.corvee{
font: italic bold;
font-size: 180%;
color: #333333;
}
h4.corvee{
font: italic bold;
font-size: 180%;
color: #333333;
font-weight: bold;
}
.afwezig{
font: italic bold;
font-size: 180%;
color: #333333;
}
h4.afwezig{
font: italic bold;
font-size: 180%;
color: #333333;
font-weight: bold;
}
.ziek{
font: italic bold;
font-size: 180%;
color: #333333;
}
h4.ziek{
font: italic bold;
font-size: 180%;
color: #333333;
font-weight: bold;
}
.extra{
font: italic bold;
font-size: 180%;
color: #333333;
}
h4.extra{
font: italic bold;
font-size: 180%;
color: #333333;
font-weight: bold;
}
h4.mededeling{
font: bold;
text-decoration: underline;
font-size: 180%;
color: #333333;
}
.mededeling{
font-size: 150%;
color: #333333;
}
</style>
</head>
<script>
/*window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
(function smoothscroll(){
var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
if (currentScroll > 0) {
window.requestAnimationFrame(smoothscroll);
window.scrollTo (0,currentScroll - (currentScroll/5));
}
})();
}
};*/
/*window.onscroll = function() {
var d = document.documentElement;
var offset = d.scrollTop + window.innerHeight;
var height = d.offsetHeight;
console.log('offset = ' + offset);
console.log('height = ' + height);
if (offset === height) {
alert("At the bottom")
}
};*/
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
alert("you're at the bottom of the page");
}
};
function countdown() {
var count = 8;
var timerId = setInterval(
function() {
count--;
console.log(count);
document.getElementById("timer").innerHTML = count;
if(count == 0) {
count = 8;
window.scrollBy(0, 685);
}
if(count == 1) {
}
if(count == 2) {
}
}, 1000);
}
countdown();
</script>
<body onload="doRedirect(); show5(); pie();" cz-shortcut-listen="true">
<?php
$datum = date("d-m-Y");
$url = 'http://rooster.kajmunk.nl/wijzigingen/18-12-2017';
$urlmed = 'http://rooster.kajmunk.nl/mededelingen/18-12-2017';
$urlhtml = file_get_contents($url);
$urlhtmlmooi = strstr($urlhtml, '<table');
$urlhtmlmooi1 = str_replace('<thead><tr><th width="15%">Klas</th><th width="20%">Uur</th><th width="33%">Nieuwe situatie</th><th width="33%">Oude situatie</th></tr></thead>','',$urlhtmlmooi);
$urlhtmlmooi2 = str_replace('<tr class="','<tr class="tr ',$urlhtmlmooi1);
$urlhtmlsupermooi = str_replace("roosterwijzigingen","centered striped mijntafel",$urlhtmlmooi2);
$urlmedhtml = file_get_contents($urlmed);
$urlmedhtmlmooi = strstr($urlmedhtml, '<div class="content"');
$urlmedhtmlsupermooi1 = str_replace(' class="content"',"",$urlmedhtmlmooi);
$urlmedhtmlsupermooi2 = str_replace('<h1>','<h1 class="extra">',$urlmedhtmlsupermooi1);
//$urlmedhtmlsupermooi2 = str_replace(' class="mededeling"',"",$urlmedhtmlsupermooi1);
$urlmedhtmlsupermooi = str_replace('h1','h4',$urlmedhtmlsupermooi2);
//$tussendoor1 = str_replace(' class="ziek"',"",$urlmedhtmlmooi1);
//$tussendoor2 = str_replace(' class="corvee"',"",$tussendoor1);
//$urlmedhtmlsupermooi = str_replace(' class="afwezig"',"",$tussendoor2);
?>
<h2 id="timer" class="timer">timer...</h2>
<div style="width:74%; position:fixed; float: left"><table class="mijntafeltop white centered striped"><thead><tr class="mijntafeltop"><th width="15%">Klas</th><th width="20%">Uur</th><th width="33%">Nieuwe situatie</th><th width="33%">Oude situatie</th></tr></thead></table></div>
<div style="width:74%; top: 1%; float: left"><?php echo $urlhtmlsupermooi;?></div>
<div class="card-panel teal darken kaaart klok" style="width:24%; height:16%; right: 1%; top: 2%; position:fixed;"></div>
<script src="js/liveclock.js" language="JavaScript">
</script>
<div class="klok" id="liveclock"><i class="large material-icons">school</i><h2>Uur kapot<br>Klok kapot</h2></div>
</div>
</div>
<div id="spacing"></div>
<div id="wrapper">
<div id="content" class="">
<script>var duration = 0;</script>
<script language="JavaScript">
duration = 7000
var sTargetURL = ""
function doRedirect() {
setTimeout( "timedRedirect()", 7000 );
}
function timedRedirect() {
}
$('body').keyup(function (event) {
if (event.keyCode == 37) {
}
else if (event.keyCode == 39) {
}
});
</script>
</div>
</div>
<script type="text/javascript">
var timer;
var timerCurrent;
var timerFinish;
var timerSeconds;
function drawTimer(percent)
{
var html = '<div id="slice"'+(percent > 50?' class="gt50"':'')
+ '><div class="pie"></div>' + ( percent > 50 ?'<div class="pie fill"></div>' : '') + '</div>';
$('div.timer').html(html);
var deg = 360/100*percent;
$('#slice .pie').css({
'-moz-transform':'rotate('+deg+'deg)',
'-webkit-transform':'rotate('+deg+'deg)',
'-o-transform':'rotate('+deg+'deg)',
'transform':'rotate('+deg+'deg)'
});
}
function stopWatch()
{
var seconds = (timerFinish-(new Date().getTime()))/1000;
if (seconds <= 0)
{
drawTimer(100);
clearInterval(timer);
$('input[type=button]#watch').val('Start');
/* alert('Finished counting down from '+timerSeconds); */
} else {
var percent = 100-((seconds/timerSeconds)*100);
drawTimer(percent);
}
}
function pie()
{
console.log(duration);
timerSeconds = duration/1000;
timerCurrent = 0;
timerFinish = new Date().getTime()+(timerSeconds*1000);
timer = setInterval('stopWatch()',50);
};
$(document).ready(function() {
$.post( "http://localhost", { timestamp : $.now() });
});
</script></div>
<div class="card-panel white kaaart" style="width:24%; height:65%; right: 1%; top: 20%; position:fixed;"><?php echo $urlmedhtmlsupermooi; ?></div>
</body>
<button id="button" style="display: none;" onclick="scrollWin()">Scroll down</button>
最佳答案
这应该有效:
function countdown() {
var count = 8;
var timerId = setInterval(
function() {
count--;
console.log(count);
document.getElementById("timer").innerHTML = count;
if(count == 0) {
count = 8;
if (document.documentElement.scrollTop >= document.documentElement.scrollHeight - document.documentElement.offsetHeight) {
window.scrollTo(0, 0);
}
else {
window.scrollBy(0, 685);
}
}
if(count == 1) {
}
if(count == 2) {
}
}, 1000);
}
关于javascript - 如何自动滚动到底部,如果在底部则滚动到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47847261/
我正在尝试向图像顶部和底部的 ImageView 添加渐变。我不想在 ImageView 之上添加 TextView 。我该如何实现? 最佳答案 看来您简单而干净的解决方案是用 FrameLayout
我可以寻求帮助吗, 我有日期 - “公司名称”和“日期”,例如 $value |"Comp Name"| "Date" | |:----------|----------:| |computer
我有两个表,我试图从中运行查询以返回每个人的最大(或最高)交易。我应该注意,我无法更改表结构。相反,我只能拉数据。 人 +-----------+| id | name |+-----------+|
所以我有一个用管道打开的 n 个流的数组,但是使用 gdb,我发现当我尝试关闭流或管道的写入端时程序失败。我可以很好地写入管道,但关闭它们不起作用。我在程序上运行 valgrind,它所做的只是打印出
大家好,这是我的难题。我正在尝试创建一个标签栏,该标签栏从上到下锚定在左侧,而不是从左到右锚定在底部。我创建了一个工具栏项目,将栏准确地放置在我想要的位置,但我希望选项卡栏相同,具有相同的功能,当然除
http://jsfiddle.net/GuXQZ/3/ header slideshow lates Content
我的图片出了点问题,我无法解决这个问题。这是我的代码.. HTML HIDE CSS #ads { -webkit-border-bottom-right-r
我有一个包含 3(css 网格)列的设计。第二列有嵌套的网格内容需要垂直滚动,而其他两列保持各自的高度。我给第二个嵌套列一个溢出,但我还需要给它一个顶部和底部填充或边距。我的解决方案没有顶部/底部填充
我在 View 中有两个 UIToolbar,分别在顶部和底部。我正在尝试在 iOS 版本中一致地应用外观。从 iOS5 开始有这个 setBackgroundImage: forToolbarPos
一个 div 我使用 top:-26px; 在 css 中设置高度。我有其他 div 其他地方我想与那个 div 对齐。我注意到在 jquery 中编写 .css('top') 得到了我的 css 而
我有这个无序列表 two three 有没有一种方法可以将无序列表添加到无序列表的前面,使其像这样结束? ONE two three 请注意“ONE”已添加到列表
我想检测鼠标何时离开顶部的视口(viewport)(可以说是向北)。我在网上搜了下How can I detect when the mouse leaves the window? .是一个好的开始
运行顶级命令top -c在 Ubuntu 服务器上显示当前正在运行的所有命令。关于 PostgreSQL 命令,括号中的值是什么意思?我说的是图片中红色框旁边的值。 最佳答案 我找不到任何文档来支持这
我想知道将顶部和底部边距添加到 GtkTextView 的正确且普遍接受的方法位于 GtkScrolledWindow 内.有设置左右边距的功能,我正在使用: gtk_text_view_set_le
作为很多“初学者”,我认为使用 TOP_OF_PIPELINE 作为 dst 和 BOTTOM_OF_PIPELINE 作为 src 意味着 ALL_COMMANDS 两者。 Here Nicol B
我正在尝试使用 jQuery/Javascript 解决这个问题: 当浏览器向下滚动且窗口底部到达页脚 DIV 顶部时,执行 CSS 代码更改。 问题示例: https://elodywedding.
我想使用范围 slider 来选择一个值并将该值呈现在 Angular 中的范围选择器顶部。我的html代码是: Raio: {{raio}} metros 在我的 co
我想将手的图片放在靠近脸部的黑色 Canvas 上。这可以吗?有没有办法确定图片的位置? 这是我的代码: var canvas; var canvasContext; window
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我是一名优秀的程序员,十分优秀!