Mengapa item menu lungsur turun tidak muncul?
P粉304704653
P粉304704653 2023-09-12 15:22:22
0
1
595

Saya menggunakan Bootstrap 5 untuk bar navigasi saya. Masalahnya ialah item lungsur turun untuk ikon pengguna (log masuk) tidak muncul. Ini kod saya:

<button class="btn dropdown-toggle" type="button" id="userDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="fa-solid fa-user text-white fs-5"></i>
            </button>
            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
                <a class="dropdown-item" href="#">Login</a>
            </div>

P粉304704653
P粉304704653

membalas semua(1)
P粉546257913

Untuk Boostrap 5 anda perlukan data-bs-toggle="dropdown" 而不是 data-toggle:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
    
<button class="btn dropdown-toggle" type="button" id="userDropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <i class="fa-solid fa-user text-white fs-5"></i>
</button>            
            
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
    <a class="dropdown-item" href="#">Login</a>
</div> 
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan