在XML里面使用级联样式表,决定数值是内联(inline)或者是作为块显示(block)到底区别在哪里?
如果内联显示,下一个元素就将被视作与前一个元素同行显示,而以块显示,每个元素就会被视为独立的。但是尽管作为单独的元素,为什么仍然显示在同一行?谢谢!

解决方案 »

  1.   

    各种 html 标记有不同的换行属性列1:
    <div>
      <div>a</div>
      <div>b</div>
    </div>
    默认情况外层 div 作为块显示(block),"a" 和 "b" 分两行显示;如果外层 div 设为内联(inline),那么 "a" 和 "b" 显式在同一行。列2:
    <div>a<br>b</div>
    由于 br 为强制换行,无论外层 div 如何设置,"a" 和 "b" 始终分两行显示。
      

  2.   

    谢谢详细的回答,我的XML代码如下:
    <?xml version = "1.0"?>
    <?xml:stylesheet href = "books.css" type = "text/css" ?>
    <books>
    <book>
       <title>Begining ASP.NET</title>
       <ISBN>1-861005-04-0</ISBN>
       <authors>
          <author_name>Chris Ullman</author_name>
          <author_name>Ollie Cornes</author_name>
          <author_name>John Kauffman</author_name>
          <author_name>Rob Birdwell</author_name>
          <author_name>Chris Goode</author_name>
          <author_name>Daniel Kent</author_name>
          <author_name>Srinavasa Sivakumar</author_name>
          <author_name>Juan Llibre</author_name> 
       </authors>
       <description>ASP.NET is a powerful technology for dynamically creating web site content.Learn how to create exciting pages that are tailored to your audience.Enhance your web/intranet presence with powful
    web applications.</description>
       <price US = "$49.99"/>
    </book>
    </books>
    books.csstitle{
          display:block;
          font-family:Arial,Helvetica;
          font-weight:bold;
          font-size:20pt;
          color:#9370db;
          text-align:center;
          }
    ISBN {
          display:block;
         
          font-family:Arial,Helvetica;
          font-weight:bold;
          font-size:12pt;
          color:#c71585;
          text-align:left;
         }
    authors{
            display:inline;
            font-family:Arial,Helvetica;
            font-style:italic;
            font-size:10pt;
            color:#9370db;
            text-align:left;
           }
    description{
                display:block;
                font-family:Arial,Helvetica;
                font-size:12pt;
                color:#ff1010;
                text-align:left;
               }为什么这里AUTHORS不管用inline还是block都是在一行显示。
      

  3.   

    你把 book.css 換成以下即可title{
          display:block;
          font-family:Arial,Helvetica;
          font-weight:bold;
          font-size:20pt;
          color:#9370db;
          text-align:center;
          }
    ISBN {
          display:block;
         
          font-family:Arial,Helvetica;
          font-weight:bold;
          font-size:12pt;
          color:#c71585;
          text-align:left;
         }
    author_name{
            display:block;
            font-family:Arial,Helvetica;
            font-style:italic;
            font-size:10pt;
            color:#9370db;
            text-align:left;
           }
    description{
                display:block;
                font-family:Arial,Helvetica;
                font-size:12pt;
                color:#ff1010;
                text-align:left;
               }
      

  4.   

    display:block; 与 display:block; 针对的都是在同一层次的标签的摆放位置据此,你在 book.xml 多加一个<authors> 节点,换成以下试试<?xml version = "1.0"?>
    <?xml:stylesheet href = "books.css" type = "text/css" ?>
    <books>
    <book>
       <title>Begining ASP.NET</title>
       <ISBN>1-861005-04-0</ISBN>
       <authors>
          <author_name>Chris Ullman</author_name>
          <author_name>Ollie Cornes</author_name>
          <author_name>John Kauffman</author_name>
          <author_name>Rob Birdwell</author_name>
          <author_name>Chris Goode</author_name>
          <author_name>Daniel Kent</author_name>
          <author_name>Srinavasa Sivakumar</author_name>
          <author_name>Juan Llibre</author_name> 
       </authors>
       <authors>
          <author_name>Chris Ullman</author_name>
          <author_name>Ollie Cornes</author_name>
          <author_name>John Kauffman</author_name>
          <author_name>Rob Birdwell</author_name>
          <author_name>Chris Goode</author_name>
          <author_name>Daniel Kent</author_name>
          <author_name>Srinavasa Sivakumar</author_name>
          <author_name>Juan Llibre</author_name> 
       </authors>
       <description>ASP.NET is a powerful technology for dynamically creating web site content.Learn how to create exciting pages that are tailored to your audience.Enhance your web/intranet presence with powful
    web applications.</description>
       <price US = "$49.99"/>
    </book>
    </books>
      

  5.   

    楼上的说得对,添加一个AUTHOR节点就可以,但是这样未免代码太冗余了吧?
    光用block换成inline效果还是一样的。
      

  6.   

    狂晕,这样解释还不明白??
    那我再说一遍display:block; 与 display:inline; 针对的都是在同一层次的标签的摆放位置如你的 book.xml 
    你若想让 <authors> 中的 <author_name> 不在同一行显示
    你需要指定的 <author_name> 的 display:block; 样式,而不是 <authors> 的样式author_name{
            display:block;
            font-family:Arial,Helvetica;
            font-style:italic;
            font-size:10pt;
            color:#9370db;
            text-align:left;
           }
    因为与 <authors> 在同一层的是<title> <ISBN> <description> 等节点
    所以你在样式中指定的 <authors> 样式
    仅限定 <authors> 与相邻节点 <ISBN> <description> 的位置关系
    authors{
            display:inline;
            font-family:Arial,Helvetica;
            font-style:italic;
            font-size:10pt;
            color:#9370db;
            text-align:left;
           }我的第二个回复让你多加一个 <authors> 的意思是,使你体会
    authors{display:inline;}的限定范围这样解释你明白否??