【问题标题】:django social share button iconsdjango 社交分享按钮图标
【发布时间】:2021-09-26 05:53:41
【问题描述】:

我正在尝试添加将锻炼帖子分享到社交媒体的功能,发现 django-social-share 包是最好的。

一切正常,但我很好奇如何在链接上添加一个图标,因为它目前看起来像

Post to Facebook!

这是非常平淡的。我见过添加 CSS 的示例,但由于该包的工作方式类似于

{% post_to_facebook object_or_url "Post to Facebook!" %}

我不确定您如何使用 CSS 来定位它。任何帮助表示赞赏。

【问题讨论】:

    标签: html css django django-templates


    【解决方案1】:

    您可以覆盖所有templates,然后添加icon 或更改style..

    所有模板目录必须按此顺序:

    Templates
      |__ django_social_share
           |__ templatetags
                 |__ post_to_facebook.html
                 |__ post_to_twitter.html
                 |__ send_email.html
                 |__ ......
                 |__ ADD ALL TEMPLATES
    

    例如。 post_to_facebook.html:

    <div class="facebook-this">                
        <a href="{{ facebook_url }}" class="{{ link_class }}" target="_blank"><i class="fa fa-facebook-square" aria-hidden="true"></i> Post to Facebook!</a>
    </div>
    

    See All Templates Here...

    【讨论】:

    • 我有点困惑。所以我会在项目中创建一个新的模板文件夹,然后按照结构为我想要图标的社交链接创建新的 html 文件?
    • @timrockx 是的,首先创建模板文件夹,然后在 settings.py 中注册(在 TEMPLATES/Dir 中),然后在其中创建模板。但是请记住文件/文件夹结构和文件名必须相同 @ 987654322@
    猜你喜欢
    • 1970-01-01
    • 2014-02-26
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 2023-02-08
    • 1970-01-01
    • 2022-01-19
    相关资源
    最近更新 更多