gpt4 book ai didi

c# - 在 C# 服务器端覆盖 css.after 和 .before

转载 作者:行者123 更新时间:2023-11-28 09:43:23 25 4
gpt4 key购买 nike

我有这样的代码:

string UserPic="images/1.png";
DataTable Chat_dt = new SQLHelper(SQLHelper.ConnectionStrings.WebSiteConnectionString).getQueryResult(query);
if (Chat_dt.Rows.Count > 0)
{
foreach (DataRow row in Chat_dt.Rows)
{
if (row["MESSAGE_SENDER_ID"].ToString() == UserID)
{
ToAppend += "<div class='bubbledLeft' >"
+ row["MESSAGE_BODY"].ToString()
+ "</div>";
}
else
{
ToAppend += "<div class='bubbledRight' >"
+ row["MESSAGE_BODY"].ToString()
+ "</div>";
}
}

}

CSS

.bubbledLeft:after{
z-index: -1;
position: absolute;
left: -36px;
width: 32px;
bottom: 0px;
height: 32px;
content:"";

/*background-image: url(left_chatter.png);*/
background-size: 32px 32px;
background-position: bottom left;

border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-o-border-radius: 3px;
-ms-border-radius: 3px;
}

我的问题是如何从服务器端函数修改 .bubbledLeft:after background-image 并将其设置为 UserPic?这可能吗?

**PS:** 服务器端函数是一个 ajax 请求,成功后我将生成的 html 附加到一个 div 中

最佳答案

我们可以按照我评论中的建议做一些事情,但是看起来你可以只附加一个 <style></style>.bubbledLeft:after 的某种风格的回应覆盖当前样式(如果需要,甚至使用 !important 标志):

//if the style does not override, you can try using the !important flag
ToAppend += "<style>.bubbledLeft:after { background-image: url(...); }</style>";

关于c# - 在 C# 服务器端覆盖 css.after 和 .before,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25339614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com