日期:2014-05-18  浏览次数:20499 次

问个web自定义控件的问题
代码如下,我想问下右边部分怎么跟左边部分对齐呢?下面代码的效果是右边部分和左边部分中的详细信息对齐,是和整个左半边错开的,或许是style定义错了?求教各位大侠,谢谢!
C# code

   {//左边部分

                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID + "_left");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "25%");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.TextHeight + "px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "微软雅黑");
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "16px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "center");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline-block");
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#B9B9B9");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                
                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID + "_leftname");
                writer.AddStyleAttribute(HtmlTextWriterStyle.MarginTop, "2px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "80px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "80px");
                writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImgUrl);
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID + "_details");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "*");
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "微软雅黑");
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "16px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "center");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.Write("详细信息");
                
                writer.RenderEndTag();
                writer.RenderEndTag();
            }
            {//右边部分
                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID + "_right");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "75%");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.TextHeight+"px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "微软雅黑");
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "16px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline-block");
                writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "left");
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#FFE4FF");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.Write(this.Text);
                writer.RenderEndTag();
            }




 
 
 
 
----------------------------------签----------名----------栏----------------------------------上班,周末,上班,周末

------解决方案--------------------
你运行页面 然后用FireBug 实时调一下样式。
这样所见即所得的修改方式比你看后台代码改要好的多了。
------解决方案--------------------
我想应该是在你设置左边和右边的时候,样式对照的写,应该会对齐的吧,自己试试看吧!