zoukankan      html  css  js  c++  java
  • div页面居中

    没事瞎写点东西..写了个div垂直居中页面中的代码.

    $(document).ready(function(){
    jQuery.fn.center = function(){
      var width = parseInt(($(window).width() - $(this).width() ) / 2 + $(window).scrollLeft()),
        height = parseInt(($(window).height() - $(this).height()) / 2 +$(window).scrollTop());
      $(this).css({
        left:width+'px',
        top:height+'px',
        position:'absolute'
      })
    };
    $('#text').center();//调用方式
    })

    <p id="text" style="300px;height:300px;border:#000 1px solid">ssss</p>

  • 相关阅读:
    申请加分项
    课程评价
    本周总结
    热词2
    热词1
    php大作业
    css网格布局
    php实验4
    本周总结
    css边框图像
  • 原文地址:https://www.cnblogs.com/taoze/p/2563334.html
Copyright © 2011-2022 走看看