在具有相同元素名称的一个XML上使用多个CSS
目前,我正在使用列出的XML文件,并附上以下两个CSS文件。我不知道为什么,但当我在CSS文件中添加前缀时,它会完全忽略该区域的格式设置 XML文件: 第二在具有相同元素名称的一个XML上使用多个CSS,xml,css,css-selectors,xml-namespaces,Xml,Css,Css Selectors,Xml Namespaces,目前,我正在使用列出的XML文件,并附上以下两个CSS文件。我不知道为什么,但当我在CSS文件中添加前缀时,它会完全忽略该区域的格式设置 XML文件: 第二 @namespace rec”http://example.com/chestershartland/recipe" 配方{ 显示:块; 左边距:20px; 边缘顶部:20px; 边框:1px纯紫色; 背景:象牙; 填充:10px; } 记录|项目名称{ 显示:无; } 配料{ 显示:块; 颜色:绿色; } 记录方向{ 显示:块; 颜色:
@namespace rec”http://example.com/chestershartland/recipe"
配方{
显示:块;
左边距:20px;
边缘顶部:20px;
边框:1px纯紫色;
背景:象牙;
填充:10px;
}
记录|项目名称{
显示:无;
}
配料{
显示:块;
颜色:绿色;
}
记录方向{
显示:块;
颜色:黑色;
边缘顶部:10px;
}
我做错了什么?如果我没有将rec或men放在CSS中,那么所有内容都会遵循recipe.CSS中关于itemName和Description的规则 这里有两个问题:
@命名空间
规则缺少分号@namespace
后跟名称空间URI
菜单.css
@名称空间”http://example.com/chestershartland/menu";
梅努伊特姆{
显示:块;
宽度:680px;
字体系列:Garamond,“泰晤士报新罗马”,泰晤士报,衬线;
字号:12号;
保证金:5px;
填充:15px;
}
itemName{/*仅适用于men:itemName元素*/
显示:块;
利润上限:10分;
左边距:15磅;
字体大小:粗体;
颜色:紫色;
}
描述{
显示:块;
左边距:40px;
}
图标{
显示:内联块;
颜色:绿色;
}
价格{
左边距:35磅;
显示:内联块;
颜色:蓝色;
}
recipe.css
@名称空间”http://example.com/chestershartland/recipe";
配方{
显示:块;
左边距:20px;
边缘顶部:20px;
边框:1px纯紫色;
背景:象牙;
填充:10px;
}
itemName{/*仅适用于rec:itemName元素*/
显示:无;
}
配料{
显示:块;
颜色:绿色;
}
方向{
显示:块;
颜色:黑色;
边缘顶部:10px;
}
谢谢!我觉得自己很傻。自从我做了css之后,这门课上已经有一些作业了,所以我完全忘记了在最后添加“;”。
<?xml-stylesheet type="text/css" href="menu.css" ?>
<?xml-stylesheet type="text/css" href="recipe.css" ?>
<men:menuItem xmlns:men="http://example.com/chestershartland/menu" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com/chestershartland/menu menu.xsd">
<men:itemName>Oatmeal Breakfast</men:itemName>
<men:description>
<![CDATA[Our oatmeal is served warm with fresh fruit, pecans, raisins,
and 100% maple syrup. Available all day.
]]>
</men:description>
<men:price>6.95</men:price>
<men:icon>♠</men:icon>
<men:icon>♥</men:icon>
<rec:recipe xmlns:rec="http://example.com/chestershartland/recipe" xsi:schemaLocation="http://example.com/chestershartland/recipe recipe.xsd">
<rec:itemName>Oatmeal Breakfast</rec:itemName>
<rec:ingredients>
<rec:ingredient>1/3 c steel cut oats</rec:ingredient>
<rec:ingredient>1-1/4 c water</rec:ingredient>
<rec:ingredient>1/4 t salt</rec:ingredient>
</rec:ingredients>
<rec:directions>
<![CDATA[Bring water to a boil. Add salt and oats, stir, and lower heat
to lowest setting. Cover and let stand 2 hours.
]]>
</rec:directions>