Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 自定义下拉列表向下推送内容_Html_Css_Positioning - Fatal编程技术网

Html 自定义下拉列表向下推送内容

Html 自定义下拉列表向下推送内容,html,css,positioning,Html,Css,Positioning,我用纯css创建了一个下拉列表,但问题是它将其他内容向下推。有人能帮忙吗 HTML: 下面是一个代码笔链接,用于我尝试执行的操作: 谢谢将选项位置从静态更改为固定 并在菜单标签上添加白色背景。找到了答案。设置的位置。选择“绝对”,将标签背景设置为白色,并向其添加z索引。静态设置为“固定”完成了操作,但现在当您单击它时,内容不再正确显示。 <div class="select"> <input id="is-focus" type="radio" name="item

我用纯css创建了一个下拉列表,但问题是它将其他内容向下推。有人能帮忙吗

HTML:

下面是一个代码笔链接,用于我尝试执行的操作:


谢谢

将选项位置从静态更改为固定
并在菜单标签上添加白色背景。

找到了答案。设置的位置。选择“绝对”,将标签背景设置为白色,并向其添加z索引。

静态设置为“固定”完成了操作,但现在当您单击它时,内容不再正确显示。
 <div class="select">
    <input id="is-focus" type="radio" name="item" />
    <label for="is-focus"><span class="label"></span></label>
    <ul class="options">
        <li>
          <input type="radio" name="item" value="pie" id="pie" />
          <label for="pie" data-title="Pie">Pie</label>
        </li>
        <li>
          <input type="radio" name="item" value="cake" id="cake" />
          <label for="cake" data-title="Cake">Cake</label>
        </li>
    </ul>
  </div>
.select {
  position: relative;
  overflow: hidden;
 }
.select .label {
  padding: 8px;
  max-width: 150px;
}
.select .label:after {
  content: "";
  position: absolute;
  left: 12px;
  top: 14px;
  border: 8px solid transparent;
  border-top-color: #999;
}
.select label {
  max-width: 150px;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  padding: 8px;
  cursor: pointer;
}
.select .options {
  max-width: 220px;
  margin: 0;
  padding: 0;
  color: #666;
  height: 0;
  border-right: 1px dotted #999;
  border-left: 1px dotted #999;
  border-radius: 5px;
  max-height: 162px;
  overflow-y: auto;
  overflow-x: hidden;
}
.select .options:hover {
  height: auto;
  border-bottom: 2px solid #999;
}
.select .options li label {
  text-align: left;
  display: block;
  padding: 6px 220px 6px 15px;
  cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
}
.select .options li label:hover {
  background-image: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
}
.select .options li [type="radio"] {
  position: absolute;
  display: block;
  left: -999px;
}
.select .options li [type="radio"]:checked ~ label:after {
  content: attr(data-title);
  display: block;
  position: absolute;
  top: 6px;
  left: 20px;
  padding: 5px 25px;
  color: #666;
  pointer-events: none;
  font-size: 80%;
  overflow: hidden;
}
.select #is-focus {
  position: absolute;
  display: block;
  opacity: 0;
  left: 150px;
}
.select #is-focus:focus ~ label span.label:after {
  border-top-color: transparent;
  border-bottom-color: #999;
  top: 0.3em;
}
.select #is-focus:focus ~ .options {
  height: auto;
  border-bottom: 2px solid #999;
}