Home > DeveloperSection > Forums > How can I hide a div using visible property even it has a background
Pravesh Singh

Total Post:411

Points:2881
Posted on    August-23-2014 7:38 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 655  View(s)
Rate this:

I have the following div:

<div visible="false"

     style="background-image:url('../Contents/Images/item-background-selected.png'); width:113px; height:58px; background-repeat: no-repeat; position: absolute;"  />

<div>

It's still visible in spite of the visible property is set to false. but when I remove the background-image from the style it's hidden.

How can I hide it with keeping its background?

Thanks in advance.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-23-2014 8:45 AM

Hi Pravesh, 

try this:

visible="false"

is a server control property, unless the div has

 runat="server"

set, it will be ignored, since the browser/client does not know how to handle that.

try CSS instead:

.myDivClass {

  display:none; /** or: visibility:hidden;  which is slightly different **/

  background-image:url('../Contents/Images/item-background-selected.png');

  width:113px;

  height:58px;

  background-repeat:

  no-repeat;

  position: absolute

}


Don't want to miss updates? Please click the below button!

Follow MindStick