python - Flask做个人网站的一些问题
巴扎黑
巴扎黑 2017-04-18 10:13:06
0
8
809

之前看完了Flask Web开发那本书,之后修修改改就做了一个比较简陋的个人网站,这两天比较有空,就打算把它改漂亮点,我的首页原本是下面这样的

真的很丑,然后这两天改成这样了

原本不懂html跟css,后来看了一点,琢磨着该出来了,但是问题来了

文章摘要要是纵向太宽了,他就跑到外面去了,这个改怎么控制,改css?

而且文章的摘要还保留了格式

我生成摘要的方法是直接post[:1000],截出来的内容带着格式,所以

文章摘要怎么清除掉格式

巴扎黑
巴扎黑

reply all(8)
大家讲道理

The problem is solved. Question and answer:
If the article abstract is too wide vertically, it will run outside. How to control this change and change the css?
Solution: Modify the css to make the text wrap automatically
How to clear the format of the article abstract
Solution: When rendering the article summary in the template, add jinja's filter striptag to remove the html tag, so that you can get a plain text article summary

左手右手慢动作

This is really worrying. I was going to use Django to build a material management system, but I got stuck as soon as I started.

刘奇

When displaying the summary, replace the format tags inside...such as <p>
these. . It can be replaced when the backend outputs data. . Also see if you can write js to replace it

左手右手慢动作

First of all, this should be a front-end problem, not a back-end problem, which means this should not be a problem between Flask and Python.

Secondly, what you need to understand is the "box" in the HTMlCSS concept.
If the text exceeds the width, you can try the css property of text wrapping.

Then you mentioned that your summary was partially intercepted using python slicing, so the original data still contains the format, is it in Html format?
If it is a format problem, you can try to filter one side of the original data in a regular way.

迷茫

It should be a css problem

黄舟

Try it
overflow: hidden;
overflow

Peter_Zhu

You can refer to one of my projects mdwiki, which is also made by flask.
The interface is based on my aesthetics, written purely in markdown.
https://github.com/xbynet/mdwiki

阿神

Why did I find that it is still ugly after the change? You can check out my blog. I am satisfied with the style. The source code is on github

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template