I had the following markup working in Bootstrap 4.
<div class="dropdown">
<span type="button" class="dropdown" data-toggle="dropdown" data-boundary="viewport">
<img src="~/images/menu.png" title="Menu" />
</span>
<div class="dropdown-menu dropdown-menu-right">
<a asp-page="AddBol" class="dropdown-item">Manual Entry</a>
</div>
</div>
However, when I upgraded to Bootstrap 5, the dropdown no longer opens.
I figured out that I need to change the data-toggle
attribute to use the data-bs-toggle
attribute instead. Now the dropdown works.
However, the data-boundary="viewport"
attribute no longer works. This attribute allows the dropdown to extend outside the container element. As it is now, the dropdown is cut off when its bounds fall outside of the container.
I tried using data-bs-boundary="viewport"
and data-bs-boundary="body"
as suggested in this question.
Does anyone know how to use this attribute in Bootstrap 5?
Update:
This is how Bootstrap is included in a new project created by Visual Studio.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - TempAspNet</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/TempAspNet.styles.css" asp-append-version="true" />
</head>