首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在asp.net代码隐藏中将背景图像设置为非平铺

如何在asp.net代码隐藏中将背景图像设置为非平铺
EN

Stack Overflow用户
提问于 2013-07-01 14:11:18
回答 1查看 2.9K关注 0票数 0

这是我用来在背景中显示图像的代码,但它是重复和平铺的。如何在后台代码中将图像设置为非平铺?我从不使用CSS来显示背景图片:

代码语言:javascript
复制
   protected void Image_Selection_Change(object sender, EventArgs e)
    {

        //PageBody.Attributes["bgColor"] = System.Drawing.Color.FromName(DropDownList1.SelectedItem.Value).Name;
        if (DropDownList1.SelectedItem.Text == "Ant and the Grasshopper")
        {
            PageBody.Attributes.Add("style", "background:url(images/ant-and-grasshopper.jpg);");
            PageBody.Attributes.Add("body", "background-repeat: no-repeat"); 
            Session["Background"] = "background:url(images/ant-and-grasshopper.jpg);";
            ImageButton9.Visible = false;
            ImageButton11.Visible = true;
        }

        if (DropDownList1.SelectedItem.Text == "Food Fit for the King")
        {
            PageBody.Attributes.Add("style", "background:no-repeat,background:url(images/King.jpg);");
            Session["Background"] = "background:url(images/King.jpg);";
            ImageButton11.Visible = false;
            ImageButton9.Visible = true;
        }

   }   

我尝试了背景-重复:没有重复,但没有用。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2013-07-01 14:15:25

代码语言:javascript
复制
"background:no-repeat,background:url(images/King.jpg);"

应该是

代码语言:javascript
复制
"background: url(images/King.jpg) no-repeat;"

除非对逗号进行特殊处理,否则两个背景属性之间的逗号不会将它们分开。只有分号可以做到这一点。此外,拥有两个背景属性会导致它们发生冲突。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17398349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档