使用 Meteor 项目约束窗口
constrain windows with meteor project
我想做的是让圆圈在屏幕上滑动,无论是垂直还是水平。我想将水平滑动的管子东西"随机"放置,但无需滚动。
但是,有时水平线会超出该区域,使整个页面变大,并需要我向下滚动才能看到它们。
这是我的代码,在Meteor/Jquery/html/css中:
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault('counter', 0);
Template.hello.helpers({});
Template.hello.events({})
function getColor(){return "rgb("+Math.floor(Math.random() * 256)+","+ Math.floor(Math.random() * 256)+","+ Math.floor(Math.random() * 256)+")"; }
var allVars = -1;
function doIT()
{
setInterval(function() {
//get unique id by count.
allVars++;
var holdName = "Circle"+ allVars;
var i =holdName;
//create the item
$div = $("<p>", {id:i, name:"circle"});
//check which direction to send it
if(allVars%2!=0){
var number = Math.floor(Math.random() * ($( "#HOLD" ).width()));
$div.css({top: -100, position:'absolute',"background-color":getColor(),width:(10+ Math.floor(Math.random() * 100))});
$div.animate({'marginLeft':number});
$("#HOLD").append($div);
var a = $( window ).height()+100;
$("#"+i).animate({height: a},5000);
}
else{
$div.css({left: -150, position:'absolute',"background-color":getColor(),height:(10+ Math.floor(Math.random() * 100))});
var n = $("#HOLD").css('width').indexOf("p");
var it = $("#HOLD").css('width').substring(0,n);
var number = Math.floor(Math.random() * (parseInt(it)));
$("#HOLD").append($div);
$("p").text(number);
$div.animate({'top':number});
var a = $( "#HOLD" ).width()+200;
$("#"+i).animate({width: a},6000);
}
}, 4000);
}
Meteor.startup(function () {
$("#HOLD").css({width:'100vw', height:'100vh'});
alert($("#HOLD").css('width'));
doIT();});
}
if (Meteor.isServer) {
}
/*
*/
[name="circle"] {
width: 50px;
height: 50px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
color: red;
text-align: center;
}
body
{
background-color: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<head>
<title>Circles</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<div id="HOLD">
<p> _ </p>
<iframe width="0" height="315" src="https://www.youtube.com/embed/B4qdpiad_Q0?&autoplay=1&loop=1&playlist=B4qdpiad_Q0" frameborder="0" allowfullscreen></iframe>
</div>
</template>
容器高度和宽度以及溢出
height:100vh;
width:100vw;
overflow:auto;
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 防止Iframe窗体在新窗口中打开
- 内部分区字体大小获胜'调整浏览器窗口大小时不会随媒体查询而更改
- 调整窗口大小时,可拖动的对象会出现在容器外部
- Javascript排序的图像弹出窗口..可以't单独弹出
- 窗口大小html css
- 弹出窗口出现,然后退出
- 为什么不是't窗口.恢复正常工作吗?(javascript/jquery)
- Javascript更新孙窗口中的表单元素
- 如何在选项卡上定义属性'的主窗口对象
- CSS-若窗口太小,滚动条会出现在“表格”单元格上
- 召回窗口加载事件 - javascript
- 为什么不显示警报窗口
- 如何使用modalDialog来显示可以在所有浏览器中工作的弹出窗口
- Chrome应用程序调整窗口大小保持纵横比
- 新选项卡被弹出窗口阻止程序阻止
- 如何访问UIWebView'的子窗口上下文
- 刷新父窗口后无法关闭窗口
- 使用 Meteor 项目约束窗口
- ExtJS 4.2 -约束窗口在最大化然后恢复后没有正确定位