首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

用css或jquery形式 使div 水平、竖直均居中

2013-01-26 
用css或jquery方式 使div 水平、竖直均居中?.className{width:270pxheight:150pxposition:absoluteleft:

用css或jquery方式 使div 水平、竖直均居中

用css或jquery形式 使div 水平、竖直均居中

?

.className{width:270px;height:150px;position:absolute;left:50%;top:50%;margin:-75px 0 0 -135px;}

?

jquery方法$(document).ready(function(){    $(window).resize(function(){  $('.className').css({   position:'absolute',   left: ($(window).width()      - $('.className').outerWidth())/2,   top: ($(window).height()      - $('.className').outerHeight())/2  }); });  // To initially run the function: $(window).resize();});

?

热点排行