2017-07-31 35 views
0

我想在我的项目中使用django tinymce,但字体太小。我已经使用它并学会了我的意思是使用content_css,但没有适当的一步一步的方法来确定这应该如何完成。Django fontsize tinymce

我想知道如果有另一种方式,如果没有,有人可以给我一个简单的一步一步的方法来解决它使用content_css。 下面是forms.py

class PostForm(forms.ModelForm): 
text = forms.CharField(help_text='Enter your Post here', widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) 
name = forms.CharField(widget=forms.HiddenInput(), initial='User') 
created_on = forms.DateTimeField(widget=forms.HiddenInput(), initial=timezone.now()) 


class Meta: 
    model = Post 
    fields = ('title', 'text',) 

{% extends 'blog/base.html' %} 
{% load staticfiles %} 

    {% block body_block %} 
    <!-- <h1>TinyMCE Quick Start Guide</h1> 
    <form method='post'> 
     <textarea id = 'mytextarea'>Hello, World!</textarea> 
    </form> --> 
    {% if post %} 
     <div class="single"> 
      <div class="container"> 
        <div class="col-md-8 single-main"> 
         <div class="single-grid"> 
          <h4><a href="{% url 'blog:detail' post.slug %}">{{ post.title|safe }}</a></h4> 
          <img src="{% static 'images/post1.jpg' %}" alt=""/> 
          <p>{{ post.text|safe }}</p> 
         </div> 
         <div class="comments"> 
          <h2><u>Comments</u></h2> 
           {% if comments %} 
            {% for comment in comments %} 
            <h3>~{{ comment.commenter.first_name|title}} {{comment.commenter.last_name|title }}</h3> 
            <ul> 
             <li> 
               {{ comment.text|safe }} 
             </</li><br> 
            </ul> 
            <span class="hidden-xs"style="margin-left:70%;, font-family:Arial">Published: {{ comment.created_on }}</span > 
            {% if comment.commenter == request.user or user.is_superuser %} 
              <a href="{% url 'blog:delete_comment' comment.id %}"><button style="margin-left:90%;,line-height: .9;color: red;, font-family:Arial;" type="button" name="button">Delete</button></a> 
            {% endif %} 

            {% endfor %} 
           {% else %} 
            No comments available 
           {% endif %} 
         </div> 
         <div class="content-form"> 
          <h3>Leave a comment</h3> 
          {% if user.is_authenticated %} 
           <form id="comment_form" action="{% url 'blog:detail' post.slug %}" method="post"> 
            {% csrf_token %} 
             {% for hidden in form.hidden_fields %} 
               {{ hidden }} 
             {% endfor %} 
             {% for field in form.visible_fields %} 
              {{ field.errors }} 

              {{ field }}<br/><br/> 
             {% endfor %} 
             <input class="btn btn-primary" type="submit" name="submit" value="submit"> 
           </form> 
           {% else %} 
           <a href="{% url 'blog:handle_login' %}">You must be logged in to comment</a> 
           {% endif %} 
           </div> 



         <ul class="comment-list " > 
           <h5 class="post-author_head">Written by <a href="#" title="Posts by admin" rel="author">{{ post.author.first_name|title }} {{ post.author.last_name|title }}</a></h5> 
           <li><img src="{% static 'images/avatar.png' %}" class="img-responsive" alt=""> 
           <div class="desc"> 
           <p>View all posts by: <a href="#" title="Posts by admin" rel="author">{{ post.author.first_name|title }} {{ post.author.last_name|title }}</a></p> 
           </div> 
           <div class="clearfix"></div> 
           </li> 
          </ul> 
        </div> 
        <div class="col-md-4 side-content"> 
         <div class="recent"> 
         <h3>RECENT POSTS</h3> 
         {% if recent_posts %} 
         <ul> 
          {% for post in recent_posts %} 
         <li><a href="{% url 'blog:detail' post.slug %}">{{post.title|title }}</a></li> 
         {% endfor %} 
         </ul> 
         {% else %} 
        <li><a href="#">No post has been posted</a></li> 
         {% endif %} 
        </div> 
        <div class="comments"> 
         <h3>RECENT COMMENTS</h3> 
         {% if recent_comments %} 
         <ul> 
          {% for comment in recent_comments %} 
         <li><a href="{% url 'blog:detail' comment.post.slug %}">{{comment.commenter|title}} on {{comment.post|title}}</a></li> 
          {% endfor %} 
         </ul> 
         {% else %} 
         <li><a href="#">No comments at the moment</a></li> 
         {% endif %} 
        </div> 
        <div class="clearfix"></div> 
        <div class="archives"> 
         <h3>ARCHIVES</h3> 
         <ul> 
         <li><a href="#">October 2013</a></li> 
         <li><a href="#">September 2013</a></li> 
         <li><a href="#">August 2013</a></li> 
         <li><a href="#">July 2013</a></li> 
         </ul> 
        </div> 
        <div class="clearfix"></div> 
        </div> 

         <div class="clearfix"></div> 
        </div> 
       </div> 
       {% if comment.commenter == request.user or user.is_superuser %} 
        <a href="{% url 'blog:delete_post' post.id %}"><button style="margin-left:90%;,line-height: .9;color: red;, font-family:Arial;" type="button" name="button">Delete Post</button></a> 
        <a href="{% url 'blog:edit_post' post.id %}"><button style="margin-left:90%;,line-height: .9;color: red;, font-family:Arial;" type="button" name="button">Edit Post</button></a> 
       {% endif %} 
     {% else %} 
     asadsh 
     {% endif %} 
     {% endblock %} 
+1

张贴代码,我推出文字。我们需要一些具体的东西来帮助你... – hansTheFranz

+0

@hansTheFranz我已经添加了detail.html – Gozie

+0

@hansTheFranz这是从 – Gozie

回答

0

要添加内容的css文件TinyMCE的,你必须改变tinymce.init对象值,包括您的content_css。

搜索脚本中初始化呼叫,并在这个例子中添加一行到你的对象,如:

tinymce.init({ 
... 
      content_css: [ 
       '//example.com/js/your-css-here.css' 
      ], 
... 
}); 

如果content_css部分已经存在,只是URL添加到阵列,即

['url 1 here', 'url 2 here', 'your new url here'] 

在您的自定义CSS文件,你现在可以设置您所需的字体大小,即

body { font-size: 14px; } 
+0

显示文本的地方我不明白content.css文件的位置。它是一个本地文件吗?你在例子中使用的是一个url。 – Gozie

+0

content_css指定了要集成到生成的代码中的其他CSS文件(例如,如果您已定义了一些您想要使用的CSS类并在您的编辑器中进行预览)。通常这些文件存储在服务器上,但也可以相对连接。关于我的例子,该文件存储在网络中的服务器上,并使用与编辑器相同的协议。你也可以指定一个相对路径,例如'/directory/anotherdir/my.css' – DatLicht