【js】 流式布局 页面
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta charset="utf-8" />
<style type="text/css">
.eblock{ position: absolute;width:200px;min-height:300px; border:1px solid #F00;}
</style>
<script src="http://r.ytrss.com/rs/js/yintaih5/h5js/lib/jquery.js"></script>
<script type="text/javascript">
$(function() {
var current;
var rowfirst;
var rowsecond;
var rowthrid;
var rowfourth;
var index = 1;
$(".eblock").each(function() {
current = $(this);
// 获取首行元素
if (index <= 4) {
if (index % 4 == 1) {
rowfirst = $(this);
} else if (index % 4 == 2) {
rowsecond = $(this);
} else if (index % 4 == 3) {
rowthrid = $(this);
} else if (index % 4 == 0) {
rowfourth = $(this);
}
}
if (index > 4) {
if (index % 4 == 1) {
current.css("top", rowfirst.position().top + rowfirst.height() + 10 + "px");
current.css("left", rowfirst.position().left + "px");
rowfirst = $(this);
} else if (index % 4 == 2) {
current.css("top", rowsecond.position().top + rowsecond.height() + 10 + "px");
current.css("left", rowsecond.position().left + "px");
rowsecond = $(this);
} else if (index % 4 == 3) {
current.css("top", rowthrid.position().top + rowthrid.height() + 10 + "px");
current.css("left", rowthrid.position().left + "px");
rowthrid = $(this);
} else if (index % 4 == 0) {
current.css("top", rowfourth.position().top + rowfourth.height() + 10 + "px");
current.css("left", rowfourth.position().left + "px");
rowfourth = $(this);
}
}
index++;
});
});
//$(function() {
// $(".eblock").each(function() {
// alert($(this).css("height"));});
//});
</script>
</head>
<body style="margin: 0 auto; margin:0">
<div style="border:1px solid #F00; top: 200px; left: 240px;" class="eblock">fdgxcv
</div>
<div style=" border:1px solid #F00; top: 200px; left: 500px;" class="eblock"> xcvxcvxv
</div>
<div style=" border:1px solid #F00; top: 200px; left: 760px;" class="eblock"> xcvxcvxv
</div>
<div style=" border:1px solid #F00; top: 200px; left: 1020px;" class="eblock"> xcvxcvxv
</div>
<div class="eblock">
</div>
<div class="eblock"> 22
</div>
<div class="eblock">23
</div>
<div class="eblock"> 24
</div>
<div class="eblock"> 31
</div>
<div class="eblock"> 32
</div>
<div class="eblock"> xcvxcvxv
</div>
<div class="eblock"> xcvxcvxv
</div>
</body>
</html>
【js】 流式布局 页面的更多相关文章
- 流式布局&固定宽度&响应式&rem
我们现在在切页面布局的使用常用的单位是px,这是一个绝对单位,web app的屏幕适配有很多中做法,例如:流式布局.限死宽度,还有就是通过响应式来做,但是这些方案都不是最佳的解决方法. 1.流式布局: ...
- webapp,liveapp: 流式布局和rem布局
liveapp场景应用,一般针对的是移动端,近来也是很火,颇有一些感受,拿来分享一下. 页面宽度范围: 一般移动端页面我们的像素范围是320px-640px,最大640px,最小320px,所以设计稿 ...
- 微信小程序电商实战-商品列表流式布局
今天给大家分享一下微信小程序中商品列表的流式布局方式,根据文章内容操作就可以看到效果哦~~~ 流式布局概念 流式布局也叫百分比布局 把元素的宽,高,margin,padding不再用固定数值,改用百分 ...
- Web前端_流式布局(百分比布局)
移动Web_流式布局(百分比布局) writer:late at night codepeasant 1(百分比布局) ☞核心知识点 1.流式布局(百分比布局) 2.视口设置 ☞今日目标 1. 能够使 ...
- 用 jQuery Masonry 插件创建瀑布流式的页面(转)
瀑布流式的页面,最早我是在国外的一个叫 Pinterest 的网站上看到,这个网站爆发,后来国内的很多网站也使用了这种瀑布流方式来展示页面(我不太喜欢瀑布流这个名字). 我们可以使用 jQuery 的 ...
- 用 jQuery Masonry 插件创建瀑布流式的页面
瀑布流式的页面,最早我是在国外的一个叫 Pinterest 的网站上看到,这个网站爆发,后来国内的很多网站也使用了这种瀑布流方式来展示页面(我不太喜欢瀑布流这个名字). 我们可以使用 jQuery 的 ...
- Python12/11--盒子的显隐/布局/z-index/流式布局思想
1.盒子的显隐 display:none 在页面中不占位,采用定位布局后,显示隐藏都不会影响其他标签,不需要用动画处理时,一般用这个 opacoity : 0 在页面中占位,采 ...
- 静态布局、自适应布局、流式布局、响应式布局、弹性布局简析、BFC
静态布局:给页面元素设置固定的宽度和高度,单位用px,当窗口缩小,会出现滚动条,拉动滚动条显示被遮挡内容.针对不同分辨率的手机端,分别写不同的样式文件.例如:浏览器窗口是1000px,那么最小的宽度是 ...
- 移动web中的流式布局和viewport知识介绍
1 流式布局 其实 流式布局 就是百分比布局,通过盒子的宽度设置成百分比来根据屏幕的宽度来进行伸缩,不受固定像素的限制,内容向两侧填充. 这样的布局方式 就是移动web开发使用的常用布局方式 ...
随机推荐
- ajax中的setRequestHeader设置请求头
1.问题引发点: 前不久发现一个问题: 前端并没有设置请求头信息里面的Accept-Encoding:gzip...但是在请求头中可以明显的看到Accept-Encoding:gzip, deflat ...
- jQuery选择器之基本过滤选择器Demo
测试代码: 03-基本过滤选择器.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...
- 51nod 约数和(数论)
题目链接: 约数和 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 有三个下标从1到n的数组a.b.c. a数组初始全为0. b[i]=∑j|ia[j] c[i]=∑j|ib[j] ...
- CentOS 6.5_X64下安装MongoDB数据库
1.下载MongoDB 官网下载地址:https://www.mongodb.org/downloads 具体链接:https://fastdl.mongodb.org/linux/mongodb-l ...
- ASP.Net 验证控件 RequiredFieldValidator
使用 ASP.NET 验证控件可在网页上检查用户输入.有用于各种不同类型验证的控件,例如范围检查或模式匹配验证控件.每个验证控件都引用网页上其他位置的输入控件(服务器控件).当处理用户输入时(例如,当 ...
- 浅谈我眼中的ASP.NET MVC
坦白地说,学习MVC是前一段时间的事情了.但是,我当时虽然也实践过,却也不能很好的说出个所以然来.因此,也 一直没敢写点什么文字总结.最近,开始学习EF,也同时在使用MVC来结合EF实践增删改查.慢慢 ...
- C#中调用API
介绍 API( Application Programming Interface ),我想大家不会陌生,它是我们Windows编程的常客,虽然基于.Net平台的C#有了强大的类库,但是,我们还是不能 ...
- 整理一下前段时间在写iOS app时所涉及的东西
在刚学习和做完一个android app后,看了两周的Objective-C就开始做这个项目,所以整个app代码有很多现学现用的东西,今天来总结一下. 这个名为VID的app是用于公司产品的研发与de ...
- OC11_真正的代理
// // ReceiveReportDelegate.h // OC11_真正的代理 // // Created by zhangxueming on 15/6/24. // Copyright ( ...
- 济南学习 Day1 T1 am
题意:给你两个日期,问这两个日期差了多少毫秒 #include<cstdio> #include<cstring> #include<ctime> #include ...