Example of Flip Card in ASP.NET MVC Card Control
This sample demonstrates how to flip(rotate) the card to show hidden information which is on back side of the card by clicking or focus-out of it.
Mayumi Ohno
Marketing Representative
Creative One
John Doe
Architecture
| johndoe@mail.com |
| 011-141-221 |
| www.johndoe.com |
@Html.UiCard(new UiCardOptions
{
Id = "card_flip", Title = "Mayumi Ohno", SubTitle = "Marketing Representative", Actions = { new UiCardAction { Text = "mayum@mail.com" }, new UiCardAction { Text = "011-232-221" }, new UiCardAction { Text = "www.mayum.com" } },
BackHtmlContent = new HtmlString("<div class=\"flip-back\"><b>Address</b><br />P.O. Box 78934<br />New Orleans<br />Los Angeles<br />Postal Code: 70117<br />USA</div>")
})
@Html.UiCard(new UiCardOptions
{
Id = "card_flip_profile",
Template = @<div class="flip-profile"><img src="@Url.Content("~/Content/card/creative_flip.png")" alt="Creative One" width="48" /><div class="flip-company">Creative One</div><div class="flip-name">John Doe</div><div class="flip-role">Architecture</div><hr /><table><tr><td>johndoe@mail.com</td></tr><tr><td>011-141-221</td></tr><tr><td>www.johndoe.com</td></tr></table></div>,
BackHtmlContent = new HtmlString("<div class=\"flip-back\"><b>Address</b><br />970 Drummond Street<br />New York<br />New Jersey<br />Postal Code: 07102<br />USA</div>")
})
<style>
.card-layout { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; max-width: 900px; margin: 0 auto; padding: 20px 0; }
.card-layout > * { flex: 0 1 380px; min-width: 260px; }
.card-layout .ui-card { width: 100%; box-sizing: border-box; }
.card-layout .ui-card + .ui-card { margin-top: 20px; }
.card-layout p { margin: 0; }
.flip-profile { text-align: left; }
.flip-profile img { display: block; margin-left: auto; }
.flip-company { text-align: right; font-weight: 600; }
.flip-name { font-weight: 600; }
.flip-role { color: var(--ui-muted); font-size: 13px; }
</style>
<div class="control-section card-control-section flip_card_layout">
<div class="card-layout">
<div>
@Html.UiCard(new UiCardOptions
{
Id = "card_flip", Title = "Mayumi Ohno", SubTitle = "Marketing Representative", Actions = { new UiCardAction { Text = "mayum@mail.com" }, new UiCardAction { Text = "011-232-221" }, new UiCardAction { Text = "www.mayum.com" } },
BackHtmlContent = new HtmlString("<div class=\"flip-back\"><b>Address</b><br />P.O. Box 78934<br />New Orleans<br />Los Angeles<br />Postal Code: 70117<br />USA</div>")
})
</div>
<div>
@Html.UiCard(new UiCardOptions
{
Id = "card_flip_profile",
Template = @<div class="flip-profile"><img src="@Url.Content("~/Content/card/creative_flip.png")" alt="Creative One" width="48" /><div class="flip-company">Creative One</div><div class="flip-name">John Doe</div><div class="flip-role">Architecture</div><hr /><table><tr><td>johndoe@mail.com</td></tr><tr><td>011-141-221</td></tr><tr><td>www.johndoe.com</td></tr></table></div>,
BackHtmlContent = new HtmlString("<div class=\"flip-back\"><b>Address</b><br />970 Drummond Street<br />New York<br />New Jersey<br />Postal Code: 07102<br />USA</div>")
})
</div>
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class CardController : Controller
{
// The page is Views/Card/FlipCard.cshtml; it draws what ViewData holds.
public ActionResult FlipCard()
{
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
Cards in this sample have a hidden content within the DOM (Document Object Model), which is set behind the visible card. On the click action handler of front card, the back-side content is shown with a flip animation.