简体   繁体   English

在表格单元格内看不到图像按钮

[英]Image button not visible inside a table cell

My html code is 我的html代码是

<tr>
    <td><input type="image" style="height:25px; width:25px;" src="plus.png"></td>
</tr>

The cell is being created but image is not showing. 正在创建该单元,但未显示图像。 However, if I use img tag, it is showing, so no problem with image's src. 但是,如果使用img标签,它将显示出来,因此图像的src没有问题。

EDIT: The CSS linked maybe the problem, but cannot figure out what:- 编辑:CSS链接可能是问题,但不能弄清楚什么:-

    *{
        font-family: Arial, sans;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
    }

    h1 {
        margin: 1em 0;
        text-align: center;
    }

    #container {
        margin: 0 auto;
        width: 50%;
    }

    #container input {
        height: 2.5em;
        visibility: hidden;
    }

    #container label {
        background: #f9f9f9;
        border-radius: 1em 1em 0 0;
        color: #888;
        cursor: pointer;
        display: block;
        float: left;
        font-size: 1em;
        height: 2.5em;
        line-height: 2.5em;
        margin-right: .25em;
        padding: 0 1.5em;
        text-align: center;
    }

    #container input:hover + label {
        background: #ddd;
        color: #666;
    }

    #container input:checked + label {
        background: #DBF3FD;
        color: #444;
        position: relative;
        z-index: 6;
        /*
        -webkit-transition: .1s;
        -moz-transition: .1s;
        -o-transition: .1s;
        -ms-transition: .1s;
        */
    }

    #content {
        background: #DBF3FD;
        border-radius: 0 .25em .25em .25em;
        min-height: 18em;
        position: relative;
        width: 100%;
        z-index: 5;
    }

    #content div {
        opacity: 0;
        padding: 1.5em;
        position: absolute;
        z-index: -100;
    }

    #content-1 p {
        clear: both;
        margin-bottom: 1em;
    }
    #content-1 p.last {
        margin-bottom: 0;
    }

    #content-2 p {
        float: left;
        width: 48.5%;
    }
    #content-2 p.column-right {
        margin-left: 3%;
    }

    #content-3 p {
        float: left;
        width: 48.5%;
    }
    #content-3 p.column-right {
        margin-left: 3%;
    }

    #container input#tab-1:checked ~ #content #content-1,
    #container input#tab-2:checked ~ #content #content-2,
    #container input#tab-3:checked ~ #content #content-3 
    {
        opacity: 1;
        z-index: 100;
    }

    input.visible {
      visibility: visible !important;
    }
    table {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
    }

    td, th {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
    }

    tr:nth-child(odd) {
        background-color: #FFFFFF;
    }
    table {
        border-collapse: collapse;
        width: 100%;
    }

    th, td {
        padding: 8px;
        text-align: left;
        border-bottom: 1px solid #ddd;
    }

    tr:hover{background-color:#96DCF7}

In your code, you write that input: 在代码中,您可以输入以下内容:

input.visible {
  visibility: visible !important;
}

But you also have: 但是您也有:

input {
  visibility: hidden;
}

You never refer to the .visible class on the code you show us, so it stays hidden. 您永远不会在显示给我们的代码上引用.visible类,因此它保持隐藏状态。 Maybe this is the problem. 也许这就是问题所在。 Try adding class="visible" to the input. 尝试将class="visible"添加到输入中。

<tr>
    <td>
       <input class="visible" type="image" style="height:25px; width:25px;" src="plus.png">
    </td>
</tr>

Try with css. 尝试使用CSS。 Add style=" background-image: url("plus.png");" 添加style=" background-image: url("plus.png");" to input tag. 输入标签。 input type="image" is not valid property of type attribute. input type="image"是type属性的无效属性。

This seems to be a problem with the other code interacting with your html. 这似乎是与您的html交互的其他代码的问题。 The following code works for me: 以下代码对我有用:

<table>
  <thead>
    <tr>
      <th>Image</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><input type="image" src="Image.png"></td>
    </tr>
  </tbody>
</table>

Maybe you should start here and then add your styles back little by little until you find whatever caused the problem. 也许您应该从这里开始,然后一点一点地添加样式,直到找到导致问题的原因。

EDIT: I copied all the code you have put here and assumed that you had a div with an id of container and another div with an id of content and that your table lived in there. 编辑:我复制了您在此处放置的所有代码,并假定您有一个具有容器ID的div和另一个具有内容ID的div,并且您的表位于其中。 Following @Benjamin Naesen's advice I set the visibility to visible and the picture appeared. 按照@Benjamin Naesen的建议,我将可见性设置为visible,然后图片出现了。

input.visible {
  visibility: visible;
}

Did this work for you? 它能为您提供帮助吗?

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

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