简体   繁体   中英

Change position of checkbox in dropdown menu

I used this snap of code to create a dropdown menu that includes textboxes: https://stackoverflow.com/a/27547021

Now, i would like to move the position of this dropdown menu to align with a certain piece of tekst. Ideally, I would like it to be at the right side of the 'Tekstpiece'. I tried to adjust the CSS, as can be seen here: https://www.w3schools.com/code/tryit.asp?filename=GDUL1WPE82S0

However, the contents of the dropdown box do not move along with the box itsself. Furthermore, hardcoding the position is likely not the best option.

Any thoughts on how this can be pulled off?

Change your html to this:

<!DOCTYPE html>
<html>
<h3>Tekstpiece</h3>
<form>
  <div class="multiselect">
    <div class="selectBox" onclick="showCheckboxes()">
      <select>
        <option>Select an option</option>
      </select>
      <div class="overSelect"></div>
      <div id="checkboxes">
      <label for="one">
        <input type="checkbox" id="one" />First checkbox</label>
      <label for="two">
        <input type="checkbox" id="two" />Second checkbox</label>
      <label for="three">
        <input type="checkbox" id="three" />Third checkbox</label>
    </div>
    </div>
  </div>
</form>
</html>

Assuming that you want the dropdown checkboxes want to be "lined up" with the select box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM