网络编程
位置:首页>> 网络编程>> Asp编程>> 解释FCKeditor样式的工作原理

解释FCKeditor样式的工作原理

作者:mickeyboy 来源:蓝色理想 发布时间:2007-10-11 13:34:00 

标签:FCKeditor,样式,style

FCKeditor的样式设置涉及到了两个文件,一个是你定义好的样式表文件.css,另一个是告诉fck样式表如何使用的xml文件,两个文件确一不可。

 css文件的位置是不做要求的,但是需要你在应用的编辑器的页面上插入样式表文件的链接。这样才能显示出来样式。

fckstyles.xml 在与editor目录同级的目录下。该文件定义了那些样式可以使用在那些标签里面。

这就是FCKeditork自带的样式xml定义



<?xml version="1.0" encoding="utf-8" ?>
<Styles>
    <Style name="Image on Left" element="img">
        <Attribute name="style" value="padding: 5px; margin-right: 5px" />
        <Attribute name="border" value="2" />
        <Attribute name="align" value="left" />
    </Style>
    <Style name="Image on Right" element="img">
        <Attribute name="style" value="padding: 5px; margin-left: 5px" />
        <Attribute name="border" value="2" />
        <Attribute name="align" value="right" />
    </Style>
    <Style name="Custom Bold" element="span">
        <Attribute name="style" value="font-weight: bold;" />
    </Style>
    <Style name="Custom Italic" element="em" />
    <Style name="Title" element="span">
        <Attribute name="class" value="Title" />
    </Style>
    <Style name="Code" element="span">
        <Attribute name="class" value="Code" />
    </Style>
    <Style name="Title H3" element="h3" />
    <Style name="Custom Ruler" element="hr">
        <Attribute name="size" value="1" />
        <Attribute name="color" value="#ff0000" />
    </Style>
</Styles>


每一个<style>将来会生成一个样式的菜单项。name名称就是显示在菜单里的文字 ;element定义了该样式可以应用在那种html标签上,<Attribute>的 name 指定了将会修改标签的哪个属性来应用样式 ,value则是修改成的值看这个:
   


 <Style name="Title" element="span">
        <Attribute name="class" value="Title" />
    </Style>


如果你在fck选定了文字 “经典论坛 &raquo; 前台制作与脚本专栏 &raquo; FCKeditor 实战技巧 - 1 &raquo; 编辑帖子” 应用该样式 则原来文字就会变成<span class="Title">经典论坛 &raquo; 前台制作与脚本专栏 &raquo; FCKeditor 实战技巧 - 1 &raquo; 编辑帖子</span>

注意:如果编辑器呈整页编辑状态,那么整页里面也需要插入样式表链接才能显示出来样式。

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com