简体   繁体   English

使HTML Table高度等于中间TD元素的高度

[英]Make HTML Table height equal to the middle TD elements height

I have a HTML table with 1 row. 我有1行的HTML表。 In that row there are 3 cells(td elements). 在该行中有3个单元格(td元素)。 The centre cell contains p elements & all the main content of the page. 中心单元格包含p个元素和页面的所有主要内容。 The left & right td elements contain an img element; 左右td元素包含img元素; they are images of the left & right sides blue column. 它们是左侧和右侧蓝色列的图像。

My Problem: I am trying to make the height of the table be equal to the height of the centre td element only. 我的问题:我试图使表格的高度仅等于中心td元素的高度。 And the left & right images will scale up & down according to the dimensions(height) of the centre td element. 左右图像将根据中心td元素的尺寸(高度)缩放。 But right now, the table is always 1200px in height & thats because the left & right images are 1200px in height. 但是现在,表格的高度始终为1200px,这就是因为左右图像的高度均为1200px。

I hope this makes sense & that you understand what I am attempting to do :P So I am tryinging to make the table height equal to the height of the centre td cell only. 我希望这是有道理的,并且您理解我正在尝试做的事情:P 因此,我正在尝试使工作台高度仅等于中心td单元格的高度。

Is there a way to do this in pure HTML & CSS. 有没有办法在纯HTML和CSS中做到这一点。 If not javascript will do it wont it? 如果没有JavaScript将不会吗?

.contentTable        { height: inherit; }
.tableTopPanel       { height: 6.25%; }
.tableBottomPanel    { height: 6.25%; }
.tableLeftPanel      { width: 6.25%; padding: 0; margin: 0; }
.tableRightPanel     { width: 6.25%; padding: 0; margin: 0; }
.tableCentrePanel    { background-color: #FFFFFF; }
.pageContent         { border-color: #99CCFF; border-width:thin; border-style:solid; border-right-width:thick;
                       border-bottom-width:thick; padding-top: 0.5em; border-top: 0; }

<table class="contentTable" id="test">
    <tr>
        <td class="tableLeftPanel"><img src="../Images/contentLeftBk.png" alt=""/></td>

        <td class="tableCentrePanel">
            <img class="pageHeading" src="Images/coursesHeading2.png" width="100%" alt=""/>
            <div class="pageContent" id="coursesContent">
                <p>Kazcare cooperates with <a href="http://www.weaillawarra.com/index.html">WEA Illawarra</a> to offer a range of educational courses.</p>
                <p>Some of the courses held at Kazcare Education Facilities include: </p>

                <ul class="leftCol">
                    <li>Front Line Management Courses</li>
                    <li>Cert 4 Training &amp; Assessment</li>
                    <li>Environment Courses</li>
                    <li>Music Appreciation</li>
                    <li>Craft Classes</li>
                    <li>Candle Making</li>
                </ul>
                <ul class="rightCol">
                    <li>Art Classes</li>
                    <li>Drawing Classes</li>
                    <li>Yoga</li>
                    <li>Dancing</li>
                    <li>Exercise Classes</li>
                    <li>Art History Classes</li>
                </ul>

                <br/>
                <p class="a">
                    To view the full range of WEA Illawarra courses held at KazCare please visit <a href="http://enrol.weaillawarra.com/index.html">WEA Illawarra Courses</a>.
                </p>
            </div>
        </td>

        <td class="tableRightPanel"><img src="../Images/contentRightBk.png" alt=""/></td>
    </tr>
</table>

If I were implementing a layout like this, I would likely rely on pure CSS instead of using a table. 如果我要实现这样的布局,则可能会依赖纯CSS而不是使用表。 There are numerous examples of three column layouts online, here's one example: 在线上有许多关于三列布局的示例,这里是一个示例:

http://www.manisheriar.com/holygrail/index.htm http://www.manisheriar.com/holygrail/index.htm

If you want to use the table, I suppose it depends on what the contents of your images look like - should they be vertically tiled if the page gets too long? 如果要使用该表,我想它取决于图像内容的样子-如果页面太长,是否应该垂直平铺图像? Does it need to be a certain width? 是否需要一定的宽度? There are a few options here, but having an idea of what you're trying to build would help. 这里有一些选择,但是对您要构建的内容有所了解会有所帮助。 Here are a few options: 以下是一些选择:

Hope this helps, happy coding! 希望对您有所帮助,编码愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM