Home > AI > Uncategorized

css – li 统一高度

to

 

<!DOCTYPE html>
<html>
  <head>
        <title>www.jobyme88.com</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            li{list-style:none;background:blue;margin:2px 0;color:#ffffff}
        </style>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
    </head>
<body>
<ul>
    <li>aaaa</li>
    <li>bbbbbbbbb<br/>bbbbbb</li>
    <li>cccccc<br />ccccccc<br />ccccc</li>
</ul>
    <script type="text/javascript">
        var maxheight = 0;
        for(var i = 0;i<$("li").length;i++){
            if(maxheight <= $("li").eq(i).height()){
                maxheight = $("li").eq(i).height();
            }
        }
        $("li").css('height',parseInt(maxheight)+'px');
    </script>
</body>


</html>

 

Related posts:

Leave a Reply