简体   繁体   English

桌子内的图像即使高度限制在100%,也会溢出

[英]Image inside table make it go overflow even with height blocked on 100%

I'm going crazy, I have my website( http://piscagliacostruzioni.it/ ) divided by three frames(three rows), in the first one I have a table as menu, it uses around the 30 % of height of the screen. 我快要疯了,我将自己的网站( http://piscagliacostruzioni.it/ )除以三帧(三行),在第一个中,我有一张桌子作为菜单,它使用高度的30%屏幕。 In this table i put some images, the table is set to 100% to fit the frame and the image are set to fit the cell(only in height, i don't care about width) so what i was expecting was the image to fit in height without overflow, but the result is the image going out of the frame from the bottom and not being displayed. 在此表中,我放置了一些图像,该表设置为100%以适合框架,图像设置为适合单元格(仅在高度上,我不在乎宽度),因此我期望的是图像高度合适,没有溢出,但是结果是图像从底部移出框架并没有显示。

Here is an example: https://jsfiddle.net/danipisca07/g0dpr0cL/ 这是一个示例: https://jsfiddle.net/danipisca07/g0dpr0cL/ : https://jsfiddle.net/danipisca07/g0dpr0cL/

(I used a div to simulate the frame as parent) (我使用div来模拟框架作为父框架)

<div style="height : 10%">
<table style="height: 100%; table-layout:fixed">
    <tr height="65%">
        <img src="http://piscagliacostruzioni.it/scrittariga.jpg" style="height:100%"/>
    </tr>
    <tr heigth="35%">
        <img src="http://piscagliacostruzioni.it/Contatti/contatti.jpg" style="height:100%"/>
    </tr>
</table>

Tried to set the table-layout to fixed and the image display property to block but everything was useless. 试图将表格布局设置为固定,将图像显示属性设置为阻止,但是一切都没有用。

I hope you will help. 希望您能对您有所帮助。 Thanks in advance Bye 预先感谢再见

Did you mean something like this: https://jsfiddle.net/g0dpr0cL/2/ 您的意思是这样吗: https : //jsfiddle.net/g0dpr0cL/2/

  1. Your code is missing <td> 您的代码丢失<td>
  2. All parent elements (including html and body ) needs a height. 所有父元素(包括htmlbody )都需要一个高度。

    html,body{ height:100% } html,body {高度:100%}

Okay, I solved the problem(almost), instead of the first row of the table I used only the image and under it a table with only one row. 好的,我(几乎)解决了这个问题,而不是表的第一行,我仅使用图像,而在表的下面仅包含一行。 To understand better see my website: piscagliacostuzioni.it, i've already uploaded the new solution. 为了更好地理解,请访问我的网站piscagliacostuzioni.it,我已经上传了新的解决方案。 Thanks again guys 再次感谢你们

I think your main issue is that you're missing the <td></td> elements from inside the <tr></tr> elements. 我认为您的主要问题是您丢失了<td></td>元素内部的<tr></tr> <td></td> <tr></tr>元素。

<tr>...</tr> is a table-row. <tr>...</tr>是一个表行。

<td>...</td> is a table-data (the columns inside a row) <td>...</td>是表数据(行中的列)

So having two rows will ALWAYS wrap the second image onto a second line - that's what the rows are for. 因此,拥有两行将始终将第二张图像包装到第二行上-这就是这些行的用途。

I'm not 100% sure if I understand the layout you're trying to achieve, but try the following code: 我不确定100%是否理解您要实现的布局,但是请尝试以下代码:

<div>
    <table width="100%">
        <tr>
            <td>
                <img src="http://piscagliacostruzioni.it/scrittariga.jpg" style="width:100%;"/>
            </td>
            <td>
                <img src="http://piscagliacostruzioni.it/Contatti/contatti.jpg" style="width:100%;"/>
            </td>
        </tr>
    </table>
</div>

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

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