各种 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" 始终分两行显示。
谢谢详细的回答,我的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;
<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" 始终分两行显示。
<?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都是在一行显示。
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;
}
<?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>
光用block换成inline效果还是一样的。
那我再说一遍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;}的限定范围这样解释你明白否??