欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

帶有固定占位符的下拉列表

錢諍諍2年前9瀏覽0評論

目前,標簽在邊界之外。

如何使單詞“from:”位于下拉列表邊框的頂部,并且當該值被選中時,它會保留在那里?

樣本輸出:來自:選項2

<div class="custom-select">
        <label for="dropdown">from: </label>
        <select >
            <option value="" disabled selected>From:</option>
   
            <option value="option1">Option 1</option>
            <option value="option2">Option 2</option>
            <option value="option3">Option 3</option>
          </select>
        
    </div>

.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
  font-size: 16px;
  overflow: hidden; 
}

.custom-select select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 8px 30px 8px 16px; 
  border: 1px solid #ccc;
  background-color: white;
  width: 100%;
  cursor: pointer;
   background-repeat: no-repeat;
  background-position: right center;
}

.custom-select select::-ms-expand {
  display: none;
}

.custom-select select:focus {
  outline: none;
}

.select-label {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  font-weight: bold;
  color: #555;
}

你好,試試我用bootstrap做的以下代碼

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">


<div class="form-floating">
  <select class="form-select" placeholder="From:">
    <option value="option1">Option 1</option>
            <option value="option2">Option 2</option>
            <option value="option3">Option 3</option>
  </select>
  <label> From:</label>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>