gpt4 book ai didi

css - 使用 css 时用 %20 替换空格

转载 作者:行者123 更新时间:2023-11-28 02:10:37 27 4
gpt4 key购买 nike

抱歉,标题不准确,但我的问题是:我正在尝试在代码隐藏中使用 css 设置背景图像,我想向该图像添加线性渐变,类似这样:

Image1.Style["background-image"] = "linear-gradient(toright, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 50%), url(URLImage)";

但是当我运行该页面时,它将代码中的空格替换为 %20,因此它不起作用 Url(linear-gradient(toright,%20rgba(0,0,0,0.8)% 200%,%20rgba(0,0,0,0)%2050%),%20url(.......)

*我也在代码隐藏中设置图像

我试过使用@,但没用有人可以帮帮我吗?谢谢

最佳答案

用反斜杠转义空格在这里应该有效。

Image1.Style["background-image"] = "linear-gradient(toright,\ rgba(0,0,0,0.8)\ 0%,\ rgba(0,0,0,0)\ 50%),\ url(URLImage)";

关于css - 使用 css 时用 %20 替换空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48775643/

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