再論 Blaozr CSS 隔離與 ::deep 虛擬元素
CSS隔離,CSS isolation, ::deep,
Last updated
CSS隔離,CSS isolation, ::deep,
Last updated
@using Blazor.Diagrams.Components.Renderers
<div class="custom-node @(Node.Selected ? " selected" : "")">
<MudCard>
<MudCardContent>
<MudText Typo=Typo.h6>Bot Answer</MudText>
<MudInput @bind-Value=@(Node.Answer) Placeholder="Answer" Variant=Variant.Outlined Margin=Margin.Dense />
</MudCardContent>
</MudCard>
@foreach (var port in Node.Ports)
{
<PortRenderer Port=@port></PortRenderer>
@* 此第三方元件的 CSS class 名為'.port',是客製化標的。 *@
}
</div>
@code {
[Parameter] public BotAnswerNode Node { get; set; }
}.custom-node.selected,
.custom-node.selected .port {
border: 1px solid #6e9fd4;
}
.custom-node:hover .port {
visibility: visible;
}
.custom-node .port {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #f5f5f5;
border: 1px solid #d4d4d4;
cursor: pointer;
visibility: hidden;
}
.custom-node .port:hover,
.custom-node .port.has-links {
visibility: visible;
background-color: black;
}
.custom-node .port.bottom {
position: absolute;
bottom: -10px;
left: calc(50% - 10px);
}
.custom-node .port.top {
position: absolute;
top: -10px;
left: calc(50% - 10px);
}/* 隔離的屬性在最終端的 element,此例為 [b-houkg0n40n],也就是影響範圍只有自己。 */
.custom-node.selected[b-houkg0n40n],
.custom-node.selected .port[b-houkg0n40n] {
border: 1px solid #6e9fd4;
}
.custom-node:hover .port[b-houkg0n40n] {
visibility: visible;
}
.custom-node .port[b-houkg0n40n] {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #f5f5f5;
border: 1px solid #d4d4d4;
cursor: pointer;
visibility: hidden;
}
.custom-node .port:hover[b-houkg0n40n],
.custom-node .port.has-links[b-houkg0n40n] {
visibility: visible;
background-color: black;
}
.custom-node .port.bottom[b-houkg0n40n] {
position: absolute;
bottom: -10px;
left: calc(50% - 10px);
}
.custom-node .port.top[b-houkg0n40n] {
position: absolute;
top: -10px;
left: calc(50% - 10px);
}.custom-node.selected,
.custom-node.selected ::deep .port {
border: 1px solid #6e9fd4;
}
.custom-node:hover ::deep .port {
visibility: visible;
}
.custom-node ::deep .port {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #f5f5f5;
border: 1px solid #d4d4d4;
cursor: pointer;
visibility: hidden;
}
.custom-node ::deep .port:hover,
.custom-node ::deep .port.has-links {
visibility: visible;
background-color: black;
}
.custom-node ::deep .port.bottom {
position: absolute;
bottom: -10px;
left: calc(50% - 10px);
}
.custom-node ::deep .port.top {
position: absolute;
top: -10px;
left: calc(50% - 10px);
}/* 隔離的屬性與::deep放置位置一樣。此例為 [b-houkg0n40n],將影響其子孫層元素。 */
.custom-node.selected[b-houkg0n40n],
.custom-node.selected[b-houkg0n40n] .port {
border: 1px solid #6e9fd4;
}
.custom-node:hover[b-houkg0n40n] .port {
visibility: visible;
}
.custom-node[b-houkg0n40n] .port {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #f5f5f5;
border: 1px solid #d4d4d4;
cursor: pointer;
visibility: hidden;
}
.custom-node[b-houkg0n40n] .port:hover,
.custom-node[b-houkg0n40n] .port.has-links {
visibility: visible;
background-color: black;
}
.custom-node[b-houkg0n40n] .port.bottom {
position: absolute;
bottom: -10px;
left: calc(50% - 10px);
}
.custom-node[b-houkg0n40n] .port.top {
position: absolute;
top: -10px;
left: calc(50% - 10px);
}