我正在尝试在我的项目中使用django tinymce,但字体太小了。我用谷歌搜索并了解到我的意思是使用content_css但没有正确的逐步方法来确定应该如何完成。
我想知道是否有另一种方式,如果没有,有人可以给我一个简单的一步一步的方法来解决它使用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 %}
答案 0 :(得分: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; }