我需要动态设置页面是asp.net,我的代码是
HtmlGenericControl timeliner = new HtmlGenericControl("div");
timeliner.Attributes.Add("id", "timelineContainer");
HtmlGenericControl expandall = new HtmlGenericControl("div");
expandall.Attributes.Add("class", "timelineToggle");
HtmlGenericControl para = new HtmlGenericControl("p");
HtmlGenericControl asec = new HtmlGenericControl("a");
asec.Attributes.Add("class", "expandAll");
asec.InnerText = "+ expand all";
para.Controls.Add(asec);
expandall.Controls.Add(para);
timeliner.Controls.Add(expandall);
HtmlGenericControl bline = new HtmlGenericControl("br");
bline.Attributes.Add("class","clear");
HtmlGenericControl tlm1 = new HtmlGenericControl("div");
tlm1.Attributes.Add("class", "timelineMajor");
HtmlGenericControl tlmm1 = new HtmlGenericControl("h2");
tlmm1.Attributes.Add("class", "timelineMajorMarker");
HtmlGenericControl span = new HtmlGenericControl("span");
span.InnerText = "1955";
HtmlGenericControl dl = new HtmlGenericControl("dl");
dl.Attributes.Add("class", "timelineMinor");
HtmlGenericControl dt = new HtmlGenericControl("dt");
dt.Attributes.Add("id", "32323");
HtmlGenericControl dla = new HtmlGenericControl("a");
dla.InnerText = "Test title";
dt.Controls.Add(dla);
dl.Controls.Add(dt);
tlmm1.Controls.Add(span);
tlm1.Controls.Add(tlmm1);
tlm1.Controls.Add(dl);
timeliner.Controls.Add(bline);
timeliner.Controls.Add(tlm1);
现在,对于 ID 为“timelineContainer”的第一个控件“div”,我有一个 CSS 给它一个左边框,使用这段代码我的时间线显示得很好,除了左边框,由于某种原因这个 div 的高度只有40px,因为它应该是所有孩子的父母。任何想法?