首页 文章

使用css显示图像

提问于
浏览
2

我正在尝试使用css显示图像 . 但它无论如何都不显示 . 请帮我 . 我的代码是:

//styles.css

table tr td span.glyphicon-eye-open{
	background: url("../images/private-eye.png") no-repeat;
}
//Register.php

<form method="post" id="form1">
<table align="center" width="45%" cellpadding="7px">
<tr>
<td><label>*</label><input type="text" name="email" placeholder=" Your Email" value="<?=$email?>"/></td>
</tr>
<tr>
<td><label>*</label> <input type="password" name="pass" id="passwordfield" placeholder=" Your Password" value="<?=$password?>"/>
<span class="glyphicon-eye-open"></span>  
</td>
  <tr>
<td><button type="submit" name="btn_Register">Register</button></td>
</tr>
</table>
</form>

我还包含'link rel =“stylesheet”href =“../ css / styles.css”type =“text / css”/'in head with tags

4 回答

  • 5

    那是因为你的 Span 根本没有高度 . 在您插入一些文本或通过CSS编辑其高度之前,每个 Span 都没有高度 . 例如,我在这里放了一些文字,如下:

    span.glyphicon-eye-open {
        background: url("http://beerhold.it/320/200") no-repeat;
        color: #fff;
    }
    
    //Register.php
    
    <form method="post" id="form1">
    <table align="center" width="45%" cellpadding="7px">
    <tr>
    <td><label>*</label><input type="text" name="email" placeholder=" Your Email" value="<?=$email?>"/></td>
    </tr>
    <tr>
    <td><label>*</label> <input type="password" name="pass" id="passwordfield" placeholder=" Your Password" value="<?=$password?>"/>
    <span class="glyphicon-eye-open">@@@</span>  
    </td>
      <tr>
    <td><button type="submit" name="btn_Register">Register</button></td>
    </tr>
    </table>
    </form>
    
  • -1

    改变这一行

    <span class="glyphicon-eye-open"></span>
    

    至:

    <span class="glyphicon-eye-open">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
    

    DEMO

    span.glyphicon-eye-open {
    	background: url("http://previews.123rf.com/images/arnau2098/arnau20981503/arnau2098150300166/37873708-small-squares-background-color-Stock-Photo.jpg") no-repeat;
    }
    
    //Register.php
    
    <form method="post" id="form1">
    <table align="center" width="45%" cellpadding="7px">
    <tr>
    <td><label>*</label><input type="text" name="email" placeholder=" Your Email" value="<?=$email?>"/></td>
    </tr>
    <tr>
    <td><label>*</label> <input type="password" name="pass" id="passwordfield" placeholder=" Your Password" value="<?=$password?>"/>
    <span class="glyphicon-eye-open">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>  
    </td>
      <tr>
    <td><button type="submit" name="btn_Register">Register</button></td>
    </tr>
    </table>
    </form>
    
  • 0

    现在使用以下css代码可以正常工作:

    table tr td span.glyphicon-eye-open{
    background: url("../images/private-eye.png");
    background-repeat:no-repeat;
    /*width:50px;
    height:50px;*/
    padding-left:15px;
    padding-right:15px;
    padding-bottom:2px;
    

    }

  • 3

    试试这个

    .glyphicon-eye-open{
    background: url("../images/private-eye.png");
    background-repeat:no-repeat;
    }
    

    确保包含css

相关问题