标题嵌在外框上边框的样式

代码如下:
$(function(){
$(".panel_border").each(function(){
//创建一个边框对象
var $borderPanel = $([
"<div>",
"<div class='my_panel_wrap'>",
"<div class='my_border'>",
"<div class='my_border_left'></div>",
"<div class='my_border_right'></div>",
"</div>",
"<div class='my_title'></div>",
"<div class='my_blank'></div>",
"<div class='my_content'></div>",
"</div>",
"</div>"
].join(""));

var $this = $(this);
var title = $this.attr("title");
var id = $this.attr("id");
$borderPanel.find(".my_title").html(title);//给边框添加标题
$this.replaceWith($borderPanel);//用边框对象($borderPanel),取代需要添加边框的对象( $(".panel_border") )
$borderPanel.find(".my_content").append($this);//将添加边框的对象的内容放在"<div class='my_content'></div>",中

//设置上边框(左右)
var width = $(".my_title").width();
$(".my_border_right").css("width","calc(92% - "+(parseInt(width)+20)+"px)");
var lwidth = $(".my_border_left").width();
$(".my_title").css("margin-left",(parseInt(lwidth)+10)+"px");

});
})



.my_panel_wrap{
border:1px solid #95B8E7;
border-top:none;
margin-top:20px;
}
.my_title{
height:20px;
position: absolute;
margin-top: -10px;
font-size:14px;
}
.my_content{
height: calc(100% - 25px);
width: calc(100% - 20px);
margin-left: 10px;
margin-bottom: 10px;
}
.my_border_left{
width: 8%;
border-top: 1px solid #95B8E7;
float: left;
}
.my_border_right{
float: right;
border-top: 1px solid #95B8E7;
}
.my_blank{
height:10px;
}



[img]http://dl2.iteye.com/upload/attachment/0114/1196/78964bca-a8c1-312f-90d8-933d797ef927.png[/img]


网上看到好多这样的边框,感觉挺好的,可惜没找到代码,自己粗略的写了份,在使用的时候只需要在 <div id="" class="panel_border" title="">需要加样框的内容</div>中添加id,class="panel_border",以及需要显示标题title,在使用的时候有一点需要注意,如果在同时使用其他的ui框架,需要在引入js文件时优先将该js文件引入,即jquery文件后 > 样框js文件 >其他ui框架文件,这样是防止影响其他ui框架的功能
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值