javascript - Why does div placed in td left not work?
阿神
阿神 2017-05-19 10:23:37
0
2
447
    <style type="text/css">
        .a{
        width: 50px;
        height: 50px;
        background: red;
        }
        table{
            border-collapse: collapse;
            position: relative;
        }
        td{
            width: 50px;
            height: 50px;
            border:1px solid;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td><p class="a" style="left:5![图片描述][1]0px; top: 50px;"></p></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
    <script type="text/javascript">
    var p = document.getElementsByTagName('p')[0];
    p.style.left = '20px';
    document.write(p.style.left);
    </script>

阿神
阿神

闭关修行中......

reply all(2)
Peter_Zhu

Top, right, left, and bottom in CSS must be used in combination with position, and the parent class must also have the position attribute.

小葫芦

Have you set absolute for p

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template