0

I want to insert a line break using CSS, there are two classes : select2-search-field and select2-search-choice they are coming in same div as li element Could please suggest any way I could break them to populate in two lines.

I have tried : How to insert a line break before an element using CSS

Following is the code snippet for which I want to achieve line break in

  • between class "select2-search-choice" and "select2-search-field"

    <div class="counterPartyId">
     <ul class="select2-choices">
     <li class="select2-search-choice">
     <div>ABN nv,</div>
     </li>
     <li class="select2-search-field" >
     <label for="s2id_autogen5" class="select2-offscreen"></label>
     <input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="select2-input" id="s2id_autogen5" placeholder="" style="width: 103px;" aria-activedescendant="select2-result-label-7">
     </li>
     </ul>
    </div>
    
  • Anzil khaN
    1,9841 gold badge22 silver badges32 bronze badges
    asked Mar 6, 2018 at 8:03
    4
    • Please indent your code properly. Commented Mar 6, 2018 at 8:05
    • 2
      Where's your existing CSS? Commented Mar 6, 2018 at 8:07
    • li.select2-search-choice, li.select2-search-field { display: block; } Commented Mar 6, 2018 at 8:10
    • Have a look on this answer. You only need the "after" selector: How to insert a line break before an element using CSS Commented Mar 6, 2018 at 8:15

    2 Answers 2

    1

    use css code " display: block "

    li {
     display: block;
     }
    <div class="counterPartyId">
     <ul class="select2-choices"> 
     <li class="select2-search-choice"> 
     <div>ABN nv,</div> 
     </li>
     <li class="select2-search-field" > 
     <label for="s2id_autogen5" class="select2-offscreen"></label> <input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="select2-input" id="s2id_autogen5" placeholder="" style="width: 103px;" aria-activedescendant="select2-result-label-7"> 
     </li>
     </ul>
    </div>

    answered Mar 6, 2018 at 8:13
    Sign up to request clarification or add additional context in comments.

    Comments

    0

    You just need to add 'display: block' to the li's if you want them to occupy each one row

    ul li { display: block; }
    <div class="counterPartyId">
     <ul class="select2-choices"> 
     <li class="select2-search-choice"> 
     <div>ABN nv,</div> 
     </li>
     <li class="select2-search-field" > 
     <label for="s2id_autogen5" class="select2-offscreen"></label> 
    <input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="select2-input" id="s2id_autogen5" placeholder="" style="width: 103px;" aria-activedescendant="select2-result-label-7"> 
     </li>
     </ul>
    </div>

    answered Mar 6, 2018 at 8:10

    Comments

    Your Answer

    Draft saved
    Draft discarded

    Sign up or log in

    Sign up using Google
    Sign up using Email and Password

    Post as a guest

    Required, but never shown

    Post as a guest

    Required, but never shown

    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.