用javascript处理html代码 [英] manipulating html code with javascript

查看:65
本文介绍了用javascript处理html代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好-
我有一个JavaScript问题,希望有人可以帮助我.我需要在下面的代码中添加JavaScript代码,以便表table1(红色表)占据单元格cell1的整个区域.同样,当我们调整浏览器窗口的大小时,表table1应该调整大小以占据cell1的所有空间.
这是html代码:

Hello -
I have one javascript issue and I hope someone can help me. I need to add javascript code to the code below so that the table table1 (red table) takes whole area of the cell cell1. Also Table table1 should resize itself to take all space of cell1 when we resize browser window.
Here is the html code:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <title></title>
        <style type="text/css">
        html, body {
        height: 100%;
        margin: 0;
        padding: 0;
        }
        </style>
  </head>
  <body>
  <table height=100% width=100% border=1 cellpadding=0 cellspacing=0>
    <tr><td colspan=2 height=40px></td></tr>
    <tr><td width=75% id="cell1">
        <table style="height:auto" width=100% bgcolor=red id="table1"><tr><td></td></tr></table>
        </td>
        <td></td>
     </tr>
  </table>
  </body>
</html>




在此先感谢




Thanks in advance

推荐答案

我们可以尝试将table table1的height属性设置为100%,而不是使用style ="height:auto".

Instead of putting style="height:auto" can we try having height attribute for Table table1 to 100%.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<table height=100% width=100% border=1 cellpadding=0 cellspacing=0>
<tr><td colspan=2 height=40px></td></tr>
<tr><td width=75% id="cell1">
<table height=100% width=100% bgcolor=red id="table1"><tr><td></td></tr></table>
</td>
<td></td>
</tr>
</table>
</body>
</html>





希望这对您有帮助!





Hope this helps !!


这篇关于用javascript处理html代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆