本文整理汇总了C#中Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput.AddCssStyle方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperOutput.AddCssStyle方法的具体用法?C# TagHelperOutput.AddCssStyle怎么用?C# TagHelperOutput.AddCssStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput
的用法示例。
在下文中一共展示了TagHelperOutput.AddCssStyle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BootstrapProcess
protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
if (context.HasProgressContext()) {
ProgressTagHelper progressContext = context.GetProgressContext();
if (!context.AllAttributes.ContainsName(AnimatedAttributeName))
Animated = progressContext.Animated;
if (!context.AllAttributes.ContainsName(StripedAttributeName))
Striped = progressContext.Striped;
if (!context.AllAttributes.ContainsName(DisplayValueAttributeName))
DisplayValue = progressContext.DisplayValue;
if (!context.AllAttributes.ContainsName(SrTextAttributeName))
SrText = progressContext.SrText;
}
else {
output.PreElement.SetHtmlContent("<div class=\"progress\">");
output.PostElement.SetHtmlContent("</div>");
}
output.TagName = "div";
output.TagMode = TagMode.StartTagAndEndTag;
output.Attributes.RemoveAll(DisplayValueAttributeName, SrTextAttributeName, AnimatedAttributeName,
StripedAttributeName);
output.AddCssClass("progress-bar");
output.Attributes.AddAriaAttribute("valuemin", 0);
output.Attributes.AddAriaAttribute("valuemax", 100);
output.Attributes.AddAriaAttribute("valuenow", Value);
output.Attributes.Add("role", "progressbar");
output.AddCssStyle("width", Value + "%");
if (SrText == null)
SrText = Ressources.PorgressBarCompleteSrHint;
if (DisplayValue ?? false) {
output.Content.AppendHtml(string.IsNullOrWhiteSpace(SrText)
? Value.ToString()
: Value + @" %<span class=""sr-only""> " + SrText + "</span>");
output.AddCssStyle("min-width", "2em");
}
else
output.Content.AppendHtml(@"<span class=""sr-only"">" + Value + @" % " + SrText + "</span>");
if (Animated ?? false) {
output.AddCssClass("active");
output.AddCssClass("progress-bar-striped");
}
if (Striped ?? false)
output.AddCssClass("progress-bar-striped");
if (Context.HasValue)
output.AddCssClass("progress-bar-" + Context.Value.ToString().ToLower());
}