locked
Css Adjust the space between labels RRS feed

  • Question

  • User1557998713 posted

    I have a form with several lines. Depending on the value of one Select control, some Labels and Texts controls are hidden by codebehind. Example of Form Line:

    Label1:Text1<margin>Label2:Text2<margin>Label3:Text3<margin>Label4:Text4<margin>

    1.- If I hide Label1:Text1, Label2:Text2 and Label3:Text3 it shows:
    <margin><margin><margin>Label4:Text4<margin>

    I want Label4 not to start with blank margins at the beginning of the line:
    Label4:Text4

    2.- If I hide Label2:Text2 and Label3:Text3 it shows:
    Label1:Text1<margin><margin><margin>Label4:Text4<margin>

    I want there to be only one <margin> between Label1:Text1 and Label4:Text4:

    Label1:Text1<margin>Label4:Text4.

    My Code:

    .mycss  { white-space:nowrap; margin-right:5px; }
    .labels { font-weight:bold; color:#5E5E5E; }
    
    <span class="mycss">
       <span id="Form_Label1" class="labels">   
       <asp:TextBox id="Form_Texto1">
    </span>
    
    <span class="mycss">
       <span id="Form_Label2" class="labels">   
       <asp:TextBox id="Form_Texto2">
    </span>
    
    <span class="mycss">
       <span id="Form_Label3" class="labels">   
       <asp:TextBox id="Form_Texto3">
    </span>
    
    <span class="mycss">
       <span id="Form_Label4" class="labels">   
       <asp:TextBox id="Form_Texto4">
    </span>
    


    <asp:textbox id="Form_Texto1"> </asp:textbox> <asp:textbox id="Form_Texto2"> </asp:textbox> <asp:textbox id="Form_Texto3"> </asp:textbox> <asp:textbox id="Form_Texto4"> </asp:textbox>

    Sunday, February 2, 2020 8:04 AM

Answers

  • User-525215917 posted

    Margins stay visible because you don't hide container of hidden label and textbox. If you hide Label1 and Text1 then you should also hide surrounding span.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 2, 2020 8:31 AM

All replies

  • User-525215917 posted

    Margins stay visible because you don't hide container of hidden label and textbox. If you hide Label1 and Text1 then you should also hide surrounding span.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 2, 2020 8:31 AM
  • User1557998713 posted

    My code is not clean if I have to find and hide the span containers in addition to the controls. Is there another system?

    Sunday, February 2, 2020 8:44 AM