zoukankan      html  css  js  c++  java
  • js中如何去获取外部css样式

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
    body{
    margin: 0;
    padding: 0;
    background-color: #e6e6e6;
    }

    .container{
    768px;
    margin: auto;
    padding: auto;
    background-color: #FFFFFF;
    }

    .head{
    height: 80px;
    }

    .nav{
    height: 45px;
    }

    .main{
    background-color: #00FF00;
    }

    .foot{
    100%;
    height: 45px;
    background-color: #FF0000;
    z-index: 1;
    }


    .main .left{
    float: left;
    200px;
    height: 600px;
    background-color: #E5EECC;
    }

    .main .right{
    float: left;
    568px;
    height: 600px;
    background-color: #EFEFEF;
    }

    .clearboth{
    clear: both;
    height: 0px;
    }

    </style>
    <script type="text/javascript" src="js/jquery/jquery-1.9.1.min.js" ></script>
    <script type="text/javascript">
    window.onload=function(){
    var main=document.getElementById("main");
    main.onclick=function(){
    var mainStyle = main.currentStyle? main.currentStyle : window.getComputedStyle(main, null);//加入此方法便可解决
    var w1=mainStyle.width;
    alert(w1);
    }
    }
    </script>
    </head>
    <body>
    <div class="container">
    <div class="head"></div>
    <div class="nav"></div>
    <div id="main" class="main">
    <div class="left"></div>
    <div class="right"></div>
    <div class="clearboth"></div>
    </div>
    <div class="foot">foot</div>
    </div>
    </body>


    </html>

  • 相关阅读:
    站立会议报告(7)
    团队博客(13)
    团队博客(12)
    意见评论
    团队博客(11)
    团队博客(10)
    团队博客(9)
    团队博客(8)
    站立会议报告(6)
    Java Callable
  • 原文地址:https://www.cnblogs.com/luoguixin/p/6147432.html
Copyright © 2011-2022 走看看