简体   繁体   中英

Bootstrap Dropdown menunot working

I am trying a lot of time to add the Bootstrap Dropdown menu or dropup menu and doesn't working trying to write a lot code and this is my last version of code hope find anyone help me:

<div class="card">
@if (Model.Photo == null)
{
    <img src='~/Content/default-user-image.png' style="width: 100%;">
}
else
{
    <img src='@Url.Action("Show", "Members", new { id = Model.UniqueId })' alt="@Model.Name" style="width: 100%;">
}
<div class="cardcontainer">
    <h1>@Model.Name</h1>
    <p class="cardtitle">@Model.Email</p>
    <dl>
        <dt>
            @Html.DisplayName("Addresses")
        </dt>

        <dd>
            @foreach (var item in Model.Address.Where(m => m.MemberId == Model.UniqueId))
        {
                <details>
                    <summary>@(item.Country + '-' + item.Governorate + '-' + item.District + '-' + item.Street + '-' + item.BuildingNumber)</summary>
                </details>
            }

        </dd>

        <dt>
            @Html.DisplayName("Personal ID")
        </dt>

        <dd>
            @foreach (var item in Model.PersonalID.Where(m => m.MemberId == Model.UniqueId))
        {
                <details>
                    <summary>@(item.IDType.Name + '-' + item.IDNumber)</summary>
                </details>
            }
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Phone)
        </dt>

        <dd>
            @foreach (var item in Model.Phone.Where(m => m.MemberId == Model.UniqueId))
        {
                <details>
                    <summary>@(item.PhoneType.Name + '-' + item.Code + '-' + item.Number)</summary>
                </details>
            }
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Profile)
        </dt>

        <dd>
            @foreach (var item in Model.Profile.Where(m => m.MemberId == Model.UniqueId))
        {
                <details>
                    <summary>@(item.Category.Name + '-' + item.SubCategory.Name + '-' + item.UniversityId + '-' + item.LibraryAccess)</summary>
                </details>
            }

        </dd>

        <dt></dt>
        <dd>
            <div class="dropdown">
                <i class="fa fa-plus fa-lg" style="color:#428bca;cursor:pointer;" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true"></i>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                    <li><a href="@Url.Action("Create", "Addresses",new {id=Model.UniqueId })">Address</a></li>
                    <li><a href="@Url.Action("Create", "PersonalIDs",new {id=Model.UniqueId })">Personal ID</a></li>
                    <li><a href="@Url.Action("Create", "Phones",new {id=Model.UniqueId })">Phone</a></li>
                    <li><a href="@Url.Action("Create", "Profiles",new { id=Model.UniqueId})">Profile</a></li>
                </ul>
            </div>
        </dd>
    </dl>
    @*<p>
        <div class="dropdown">
            <i class="fa fa-plus fa-lg" style="color:#428bca;cursor:pointer;" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true"></i>
            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                <li><a href="@Url.Action("Create", "Addresses",new {id=Model.UniqueId })">Address</a></li>
                <li><a href="@Url.Action("Create", "PersonalIDs",new {id=Model.UniqueId })">Personal ID</a></li>
                <li><a href="@Url.Action("Create", "Phones",new {id=Model.UniqueId })">Phone</a></li>
                <li><a href="@Url.Action("Create", "Profiles",new { id=Model.UniqueId})">Profile</a></li>
            </ul>
        </div>
    </p>*@
</div>

And this is the CSS code:

    .card {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
    max-width: 300px;
    margin: auto;
    text-align: center;
    font-family: arial;
}

.cardcontainer {
    padding: 0 16px;
}

.container::after {
    content: "";
    clear: both;
    display: table;
}

.cardtitle {
    color: grey;
    font-size: 18px;
}

.cardbutton {
    border: none;
    outline: 0;
    display: inline-block;
    padding: 8px;
    color: white;
    background-color: #000;
    text-align: center;
    cursor: pointer;
    width: 100%;
    font-size: 18px;
}

.carda {
    text-decoration: none;
    font-size: 22px;
    color: black;
}

You need the Bootstrap Javascript and jQuery must be included before it.

Also, you are missing the dropdown-toggle class in your <i> tag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM