67

<ul>对or的标题/标题进行编码的最佳方法是<ol>什么?就像我们<caption>在 中一样<table>,我们不想让它们变得粗体。

这个可以吗?

<p>heading</p>
<ul>
  <li>list item</li>
  <li>list item</li>
  <li>list item</li>
</ul>

还是应该始终使用标题?

<h3|4|5|6>heading</h3|4|5|6>
<ul>
  <li>list item</li>
  <li>list item</li>
  <li>list item</li>
</ul>

获取超过 255 个字符的列时出现 Sybase 错误

从超过 255 个字符的列中获取数据时遇到问题

我收到这样的错误消息:

Open Client Message:
Message number: LAYER = (1) ORIGIN = (4) SEVERITY = (1) NUMBER = (132)
Message String: ct_fetch(): user api layer: internal common library error: The bind of result set item 3导致截断。

它仅获取前 255 行并截断其余行。

我试图在 ct_connect 之前暗示以下行,但没有奏效

CS_BOOL boolv = CS_TRUE;
CS_RETCODE  retcode2 = ct_capability ( *connection, CS_GET, CS_CAP_REQUEST,    CS_WIDETABLES, &boolv);

这是代码的一部分,您有什么建议吗

for (i = 0; i < num_cols; i++) {
        /*
         ** Get the column description.  ct_describe() fills the
         ** datafmt parameter with a description of the column.
         */
        retcode = ct_describe(cmd, (i + 1), &datafmt[i]);
        if (retcode != CS_SUCCEED) {
            ex_error("ex_fetch_data: ct_describe() failed");
            break;
        }

        /*
         ** update the datafmt structure to indicate that we want the
         ** results in a null terminated character string.
         **
         ** First, update datafmt.maxlength to contain the maximum
         ** possible length of the column. To do this, call
         ** ex_display_len() to determine the number of bytes needed
         ** for the character string representation, given the
         ** datatype described above.  Add one for the null
         ** termination character.
         */
        datafmt[i].maxlength = ex_display_dlen(&datafmt[i]) + 1;

        /*
         ** Set datatype and format to tell bind we want things
         ** converted to null terminated strings
         */
        datafmt[i].datatype = CS_LONGCHAR_TYPE;
        datafmt[i].format = CS_FMT_NULLTERM;

        /*
         ** Allocate memory for the column string
         */
        coldata[i].value = (CS_CHAR *) malloc(datafmt[i].maxlength);
        if (coldata[i].value == NULL) {
            ex_error("ex_fetch_data: malloc() failed");
            retcode = CS_MEM_ERROR;
            break;
        }

        /*
         ** Now bind.
         */
        retcode = ct_bind(cmd, (i + 1), &datafmt[i], coldata[i].value,
                &coldata[i].valuelen, (CS_SMALLINT *) &coldata[i].indicator);
        if (retcode != CS_SUCCEED) {
            ex_error("ex_fetch_data: ct_bind() failed");
            break;
        }
    }


.............
.............
.............

    /*
     ** Fetch the rows.  Loop while ct_fetch() returns CS_SUCCEED or
     ** CS_ROW_FAIL
     */
    while (((retcode = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED,
            &rows_read)) == CS_SUCCEED) || (retcode == CS_ROW_FAIL)) {
4

6 回答 6

58

虽然这很旧,但我正在为以后搜索时可能会发现这个问题的其他人更新它。

@马特凯利赫:

对列表使用 css :beforedata- * 属性是一个好主意,但可以稍微修改一下,以便更容易访问:

HTML:

<ul aria-label="Vehicle Models Available:"> 
    <li>Dodge Shadow</li>
    <li>Ford Focus</li>
    <li>Chevy Lumina</li>
</ul>

CSS:

ul:before{
    content:attr(aria-label);
    font-size:120%;
    font-weight:bold;
    margin-left:-15px;
}

这将创建一个列表,其上方带有“header”伪元素,文本设置为 aria-label 属性中的值。然后,您可以轻松地根据需要对其进行样式设置。

与使用 data-* 属性相比,这样做的好处是 aria-label 将被屏幕阅读器读取为列表的“标签”,这对于您对该数据的预期用途而言在语义上是正确的。

注意: IE8 支持 :before 属性,但必须使用单冒号版本(并且必须定义有效的 doctype)。IE7 不支持 :before,但 Modernizer 或 Selectivizr 应该会为您解决该问题。所有现代浏览器都支持较旧的 :before 语法,但更喜欢使用 ::before 语法。一般来说,处理这个问题的最好方法是使用旧格式的 IE7/8 外部样式表和使用新格式的通用样式表,但实际上,大多数人只使用旧的单冒号格式,因为它仍然是 100% 交叉的浏览器,即使在技术上对 CSS3 无效。

于 2013-12-09T19:23:35.760 回答
48

始终使用标题标签作为标题。线索就在名字里:)

如果您不希望它们变粗,请使用 CSS 更改它们的样式。例如:

HTML:

<h3 class="list-heading">heading</h3>

<ul> 
    <li>list item </li>
    <li>list item </li>
    <li>list item </li>
</ul>

CSS

.list-heading {
    font-weight: normal;
}

如果标题和列表包含文档的一部分,则可以使用<section>元素更明确地关联标题和列表:

<section class=“list-with-heading”&gt;
    <h3>heading</h3>

    <ul>
        <li>list item </li>
        <li>list item </li>
        <li>list item </li>
    </ul>
</section>

然后样式如下:

.list-with-heading h3 {
    font-weight: normal;
}
于 2010-02-09T07:45:08.130 回答
8

我喜欢使用 css:beforedata-*列表的属性

HTML:

<ul data-header="heading"> 
<li>list item </li>
<li>list item </li>
<li>list item </li>
</ul>

CSS:

ul:before{
    content:attr(data-header);
    font-size:120%;
    font-weight:bold;
    margin-left:-15px;
}

这将创建一个带有标题的列表,该列表是指定为列表data-header属性的任何文本。然后,您可以轻松地根据需要对其进行样式设置。

于 2013-05-21T15:44:30.140 回答
4

如何使标题成为具有不同样式的列表元素,像这样

<ul>
 <li class="heading">heading</li>
 <li>list item</li>
 <li>list item</li>
 <li>list item</li>
 <li>list item</li>
</ul>

和 CSS

ul .heading {font-weight: normal; list-style: none;}

此外,使用重置 CSS 在 ul 和 li 上设置边距和填充。这是一个很好的重置CSS。一旦你重置了边距和填充,你可以在列表元素上应用一些边距,而不是标题类的元素,以缩进它们。

于 2010-02-09T08:12:56.523 回答
1

<caption>是否允许使用?

<ul>
  <caption> Title of List </caption>
  <li> Item 1 </li>
  <li> Item 2 </li>
</ul>
于 2018-10-04T15:02:50.077 回答
0

h3 绝对是比 h2、h1 或 h6 更好的解决方案!

  1. 您必须使用特定级别:如果您在 h1 中,请使用 h2,如果您在 h5 中,请使用 h6(如果您在 h6 中......嗯,例如使用 strong 或 em)。这不是一项义务,而是一个可访问性的问题(这里,绿色部分)。

  2. 您不必为列表指定标题...因为此元素不存在。所以屏幕阅读器不会使用特殊的东西。

因此,使用 Hn 可能是最好的解决方案之一,但肯定不是特定级别。

于 2010-02-09T09:29:26.517 回答