0

我是 css 新手,我正在尝试找出一种方法将图例标签合并为我的页面的标题

目前我的母版页由一个字段设置样式:

 fieldset.field_set_main
 {
     border-bottom-width:50px;
     border-top-width:100px;
     border-left-width:30px;
     border-right-width:30px;       
     margin:auto;    
     width:1300px;
     height:700px;
     padding:0px 0px 0px 0px;
     border-color:Black;    
     border-style:outset;  
     display:table;
}

legend.header
{          
     text-align:right;
}

<fieldset class="field_set_main" >
    <legend class="header">
        buy for you 
    </legend>                              
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>                                                                                  
</fieldset> 
  1. 图例标题以其自己的背景颜色“白色”出现,如果我将其设置为黑色,则只有标题文本本身“为你购买”得到黑色,它在我的边框右侧显示为一个白色框,我正在寻找图例的 css 样式显示为页面的标题(背景颜色与字段集的背景颜色相同,文本的前景色不同)。

  2. fieldset 中是否有页脚元素,我希望标题也出现在页面底部。

  3. 有用的 css 样式有什么好的资源吗?特别是对于具有主要字段集样式的母版页?
4

1 回答 1

3

听起来您正试图将其fieldset用作整个页面的容器和legend页眉。这是对这两个元素语义的误用。

如果您需要元素来包装页面以进行样式设置,我强烈建议您将标记和 CSS 更改为:

 .field_set_main {
     border: 30px solid black;
     border-bottom-width:50px;
     border-top-width:100px;
     margin:auto;    
     width:1300px;
     height:700px;
     padding: 0;
     display:table;
}

.header
{          
     text-align:right;
}

<div class="field_set_main" >
    <h1 class="header">
        buy for you 
    </h1>                              
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>                                                                                  
</div> 

众所周知,该legend领域很难始终如一地完整地设置样式,因此除非它在语义上至关重要,否则我会避免使用它,在您的情况下,听起来绝对不是这种情况。

于 2011-10-01T00:22:09.463 回答