2

I am trying to display image using css. But it is not display anyway. please help me. My code is :

//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>

I also has included 'link rel="stylesheet" href="../css/styles.css" type="text/css" /' in head with tags

6
  • "Not display" doesn't give much information. Are you sure the image is placed at the relative path you're pointing at? Try checking Network tab in Dev Tools on Chrome or Firezilla in Firefox. Commented Aug 7, 2016 at 11:56
  • I placed image in separate 'images' folder, which in given path is true. Commented Aug 7, 2016 at 11:57
  • @Sudip977 Try something like this then: 'images/private-eye.png' for ur background: url Commented Aug 7, 2016 at 11:59
  • @NickParsons but folder is not in 'css' folder Commented Aug 7, 2016 at 12:02
  • 1
    That is because your span has no height at all. Every span has no height until you insert some text in it or edit its height via CSS. Commented Aug 7, 2016 at 12:06

4 Answers 4

5

That is because your span has no height at all. Every span has no height until you insert some text in it or edit its height via CSS. For example, I've put some text in here, like so:

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>

Sign up to request clarification or add additional context in comments.

Comments

3

Change this line

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

to:

<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>

Comments

0

It now works fine using following css code :

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;

}

2 Comments

I have also used width and hieght of span, but not working.
It also works when I gives sufficient number of &nbsp; between <span> and </span>
-1

try this one

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

Make sure your css is included

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.