包含HTML格式的复选框列表的可滚动框

52 html checkbox iframe scrollable

附上你会看到我为所需UI做的模拟图片.如您所见,我需要一些包含复选框的可滚动框.

在此输入图像描述

我想到了一个可滚动的div,虽然我找不到设置div周围边框的方法?其次我想到了一个IFrame ..但也不太确定这是否是我最好的选择.

有没有人可能有更简单/更好的方法来做到这一点?

提前致谢!

Sam*_*ich 103

CSS:

.container { border:2px solid #ccc; width:300px; height: 100px; overflow-y: scroll; }
Run Code Online (Sandbox Code Playgroud)

HTML:

<div class="container">
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
    <input type="checkbox" /> This is checkbox <br />
</div>
Run Code Online (Sandbox Code Playgroud)

看起来如何:

设计

这是你想要的?

  • 完善!谢谢Samich,这正是我想要的. (2认同)

小智 6

<style type="text/css">
   select, ul { height: 100px; overflow: auto; width: 100px; border: 1px solid #000; }
   ul { list-style-type: none; margin: 0; padding: 0; overflow-x: hidden; }
   li { margin: 0; padding: 0; }
   label { display: block; color: WindowText; background-color: Window; margin: 0; padding: 0; width: 100%; }
   label:hover { background-color: Highlight; color: HighlightText; }
  </style>
<ul>
   <li><label for="chk1"><input type="checkbox" name="chk1" id="chk1">First</label></li>
   <li><label for="chk2"><input type="checkbox" name="chk2" id="chk2">Second</label></li>
   <li><label for="chk3"><input type="checkbox" name="chk3" id="chk3">Third</label></li>
   <li><label for="chk4"><input type="checkbox" name="chk4" id="chk4">Fourth</label></li>
   <li><label for="chk5"><input type="checkbox" name="chk5" id="chk5">Fifth</label></li>
   <li><label for="chk6"><input type="checkbox" name="chk6" id="chk6">Sixth</label></li>
   <li><label for="chk7"><input type="checkbox" name="chk7" id="chk7">Seventh</label></li>
  </ul>
Run Code Online (Sandbox Code Playgroud)

http://krijnhoetmer.nl/stuff/html/select-multiple-checkbox-list/