html css 蜂窝效果,jQuery CSS蜂窝布局效果

本文介绍了如何使用CSS和JavaScript创建一个动态的蜂窝效果,通过inline-block和伪元素实现网格布局,同时利用jQuery插件实现响应式和自适应的六边形边框。适合前端开发者了解CSS布局技巧和交互设计。
摘要由CSDN通过智能技术生成
CSS蜂窝效果

html,body{margin:0;padding:0;width:100%;}

#wrap{margin:0;padding:0;width:100%;}

#wrap:after{content:"";display:block;height:0;clear:both;visibility: hidden;overflow:hidden;}

.post{width:120px;height:80px;display:inline-block;background:#0099ff;float:left;border-right:1px dotted #fff;border-left:1px dotted #fff;margin-top:100px;position:relative;overflow:visible;margin-top:52px;-webkit-transition:all .3s linear;-moz-transition:all .3s linear;}

.post:before{content:"";width:0px;height:0px;display:inline-block;border-left: 60px dotted transparent; border-right: 60px dotted transparent; border-bottom: 50px solid #0099ff;font-size:0;position:absolute;top:-50px;left:0px;}

.post:after{content:"";width:0px;height:0px;display:inline-block;border-left: 60px dotted transparent; border-right: 60px dotted transparent; border-top: 50px solid #0099ff;font-size:0;position:absolute;bottom:-50px;left:0px;}

(function($){

$.fn.sixBorder = function(options){

var defaults={

post:'post'

}

var options=$.extend(defaults,options);

var wrapWidth=$(this)[0].offsetWidth,postWidth=$("."+options.post)[0].offsetWidth,lineNum=Math.floor(wrapWidth/postWidth),lineLimit=Math.floor((wrapWidth-61)/postWidth);

$("."+options.post).each(function(index){

var _this = $(this);

_this.css({'margin-left':'0px'});

if(lineLimit == lineNum){

var numPer=index%lineNum;

if(numPer == 0){

var linePer=Math.floor(index/lineNum)%2;

if(linePer == 1){

_this.css({'margin-left':'61px'});

}

}

}else{

var numPer=index%(lineLimit+lineNum);

if(numPer == 0){

_this.css({'margin-left':'61px'});

}

};

});

}

})(jQuery);

$("#wrap").sixBorder();

$(window).resize(function(){

$("#wrap").sixBorder();

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值