zoukankan      html  css  js  c++  java
  • 关于让左右2个DIV高度相等

    哪个div Height值大,就将其值赋给Height值小的div,从而使2个div高度始终保持一

    以下是代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>div高度相等</title>
    <style type="text/css">
    #left{background:#999999; float:left; 100px;}
    #right{background:#0066FF; color:#fff; 300px; float:left; }
    .clear{clear:both;}
    </style>
    </head>
    <body>
    <h3>1. 右边div内容高度高于左边div</h3>
    <div id="left">

    没有别条路能走你决定要不要陪我

    讲不听偏爱看我感觉爱

    等你的依赖

    不后悔有把握

    我不闪躲 我非要这麽做

    讲不听也偏要爱 更努力爱让你明白

    没有别条路能走你决定要不要陪我

    讲不听偏爱看我感觉爱

    等你的依赖 对你偏爱

    痛也很愉快

       </div>
    <div id="right">
    偏爱
    </div>
    <script type="text/javascript" src="js/jquery-1.12.3.js"></script>
    <script type="text/javascript">
    function $(id){
    return document.getElementById(id)
    }
    function getHeight() {
    if ($("left").offsetHeight>=$("right").offsetHeight){
    $("right").style.height=$("left").offsetHeight + "px";
    }
    else{
    $("left").style.height=$("right").offsetHeight + "px";
    }
    }
    window.onload = function() {
    getHeight();
    }

    </script>
    </body>
    </html>
  • 相关阅读:
    MAC OS系统替换homebrew使用阿里云的镜像源
    Javascript 交换两个变量的值
    Vue 中的 ref $refs
    Bluetooth M590 mouse problem Ubuntu
    Ubuntu 蓝牙鼠标的问题
    视频分享
    Vue项目中的文件/文件夹命名规范
    js打印div指定区域内容
    IntelliJ IDEA 配置
    idea安装
  • 原文地址:https://www.cnblogs.com/yf-html/p/5662471.html
Copyright © 2011-2022 走看看