Search code examples
htmlcssbordercode-behind

Why is my Border not displaying although I have set the border-style property to solid?


I have a div on my page which starts out invisible (display:none), but conditionally changes to visible (display:block).

It is defined in html this way, in the aspx file, with display set to none and given a border:

<div class="row" id="gadsDiv" runat="server" style="display:none; border-style: solid; margin-top: 
                                                                                            -2px">
    <label style="font-weight: bold; padding-left: 4px; padding-right: 4px;">GENRES: </label> 
        <asp:Label runat="server" ID="lblGenres">None or Unknown</asp:Label><br />
    <label style="font-weight: bold; padding-left: 4px; padding-right: 4px;">ACTORS: </label> 
        <asp:Label runat="server" ID="lblActors">None or Unknown</asp:Label><br />
    <label style="font-weight: bold; padding-left: 4px; padding-right: 4px;">DIRECTOR[S]: </label> 
        <asp:Label runat="server" ID="lblDirectors">None or Unknown</asp:Label><br />
    <label style="font-weight: bold; padding-left: 4px; padding-right: 4px;">WRITER[S]: </label> 
        <asp:Label runat="server" ID="lblScreenwriters">None or Unknown</asp:Label>
</div>

There is a situation which causes the div to be shown, accomplished by doing this in the code-behind (aspx.cs file):

gadsDiv.Attributes.Add("style", "display:block;");
gadsDiv.Attributes.Add("style", "border-style:solid;");
gadsDiv.Attributes.Add("style", "margin-top: -2px;");

Just to be safe, I re-apply the border-style solid attribute.

But the border does not display (it should be around the GENRES, ACTORS, DIRECTORS, WRITERS section):

enter image description here

What is preventing the border from displaying?


Solution

  • instead of using border-style: solid; use border: 1px solid #000; you can change the px and color(#000) as you want