mardi 20 décembre 2016

ASP.NET - C# - Modify an HTML tag level CSS selector

I want to be able to fully manipulate all CSS selectors (including classes and semantic tags) from the back end of a page. Like so:

CSS:

html {
    color: black;
}

.myClass {
    width: 100px;
}

Desired C#:

protected void Page_Load(...) {
    // Some code & if logic ...
    html.Attributes.Add("style", "color: green")
    myClass.Attributes.Add("style", "width: 325px")
}

However, the C# aspect of it I do not know what to do to access semantic level tags. I also was curious how to modify just the style classes from C# (i.e. do not mess with the ASP.NET / id's). This for design aspects as CSS does not have certain logic behind it and I cannot make another "html" selector in CSS or C#.

EDIT:

Class applied to a generic div element containing other elements. runat="server"




Aucun commentaire:

Enregistrer un commentaire