如何将 bootstrap 样式应用到内联 <select> 元素

问题描述 投票:0回答:1
html css thymeleaf bootstrap-5
1个回答
2
投票

遵循文档中的示例

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

<p>Post office expenses</p>
<div class="row g-3 align-items-center">
    <label for="selectYear" class="col-auto">Year:</label>
    <div class="col-auto">
        <select id="selectYear" class="form-select" th:field="*{years}" onchange="getDaysInMonth()">
            <option th:each="y : ${years}" th:value="${y}" th:text="${y}"/>
        </select>
    </div>
    <label for="selectMonth" class="col-auto">Month:</label>
    <div class="col-auto">
        <select id="selectMonth" class="form-select" th:field="*{monthsList}" onchange="getDaysInMonth()">
            <option th:each="m : ${monthsList}" th:value="${m.id}" th:text="${m.monthName}"/>
        </select>
    </div>
    <label for="selectDay" class="col-auto">Day:</label>
    <div class="col-auto">
        <select name="selectDay" id="selectDay" class="form-select">
            <option th:each="n : ${#numbers.sequence(1,31)}" th:value="${n}" th:text="${n}"/>
        </select>
    </div>       
</div>

© www.soinside.com 2019 - 2024. All rights reserved.