0

バックグラウンドで画像を表示するために使用したコードは次のとおりですが、繰り返してタイリングしています。画像を非タイリングに設定するには、コード ビハインドでどのようにすればよいですか? 背景画像を表示するためにCSSを使用することはありません:

   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;
        }

   }   

私は background-repeat: no repeat を試しましたが、役に立ちませんでした。前もって感謝します。

4

1 に答える 1

0
"background:no-repeat,background:url(images/King.jpg);"

あるべき姿

"background: url(images/King.jpg) no-repeat;"

コンマが特別に扱われない限り、2 つの背景属性の間のコンマはそれらを分離しません。それを行うのはセミコロンだけです。また、背景属性が 2 つあると、それらが競合します。

于 2013-07-01T06:15:25.237 に答える