Home  >  Q&A  >  body text

python - Flask做个人网站的一些问题

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

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

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

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

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

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

文章摘要怎么清除掉格式

巴扎黑巴扎黑2715 days ago770

reply all(8)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 10:15:06

    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

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 10:15:06

    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.

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:15:06

    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

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 10:15:06

    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.

    reply
    0
  • 迷茫

    迷茫2017-04-18 10:15:06

    It should be a css problem

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:15:06

    Try it
    overflow: hidden;
    overflow

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:15:06

    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

    reply
    0
  • 阿神

    阿神2017-04-18 10:15:06

    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

    reply
    0
  • Cancelreply