bootstrap-4 - 在 blazor 客户端中显示模态对话框

标签 bootstrap-4 blazor

我知道 Blazored Modalthis answer ,但我不想有一个特定的组件只是为了显示模态(缺乏灵活性),并希望自己在各种组件中实现代码。

这是一个非常简单的代码来显示示例模式:

@page "/fetchdata"


<button class="btn btn-primary" @onclick="@(() => { showModal = true; })">Show Dialog!</button>
@if (showModal)
{
<div class="modal-backdrop fade show" tabindex="-1" role="dialog" style="display: block;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Modal title</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <p>Modal body text goes here.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary">Save changes</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
}
<hr />

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from the server.</p>


@code {
    bool showModal = false;
}

该代码有效,但不透明度有问题:
enter image description here

推杆 style="opacity:1;"<div class="modal-dialog" role="document">也没有解决问题(尽管给出 opacity ,低于 1 的值使它更透明!)

问题的原因是什么以及如何解决?

最佳答案

不要直接使用 modal-backdrop 。使用简单的模态。 modal-backdrop 是框架应用于背景内容的内容。

关于bootstrap-4 - 在 blazor 客户端中显示模态对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62362370/

相关文章:

html - 移动布局中的 Div 顺序 - Bootstrap 4 行和列

javascript - 选择时更改背景

c# - 从选项卡注销,不适用于所有其他选项卡

blazor - 具有自定义子组件的自定义 Blazor 组件

css - SASS 错误 : Incompatible units: 'px' and 'px*px'

javascript - 当我用 bootstrap html 制作表格时,第一行与表格标题合并

javascript - 如何将 bootstrap 4 导航保持在桌面标题下方,但在移动设备上方

digital-signature - 您可以使用 Blazor 访问客户端的证书存储和签名数据吗?

blazor - 通知 EditContext 该字段已更改以进行 Blazor 验证

azure - Blazor Azure AD B2C net 5 尝试登录时出错