我知道我可以通过这种方式从代码中添加样式
imgStory1.Style.Add("display","block");
imgStory1.Style.Add("border", "none");
imgStory1.Style.Add("outline", "none");
imgStory1.Style.Add("height", "auto !important");
等等,但如果可能的话,我想以一种更有效的方式来做。请注意,我无法通过 CSS 执行此操作,它必须是内联样式。
最佳答案
这里有一种写在一行中的方法
imgStory1.Attributes.Add("style", "display: center;border: none; outline: none");
用于覆盖现有的
imgStory1.Attributes["style"] = "display: center;border: none; outline: none";
关于c# - 从后面的代码添加多个内联样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39462929/