js和ajax点赞功能代码_文章点赞功能(Ajax)

一、文章点赞样式构建

1、将base.html的css样式改为外部引入

将base.html的内嵌样式删除,改为使用 HTML 头部的 

 标签对中使用标签来引入外部的 CSS 文件。

base.html内容如下所示:

Title

{ { blog.title }}

管理

{% load my_tags %}

{% get_classification_style username %}

{% block content %}

{% endblock %}

个人站点的样式——home_site.css:

* {

margin: 0;

padding: 0;

}

.header {

width: 100%;

height: 60px;

background-color: #369;

}

.header .title {

font-size: 18px; /* 字体大小 */

font-weight: 100; /* 字体粗细 */

line-height: 60px; /* 行高与页头一致,完成居中 */

color: white;

margin-left: 15px;

margin-top: -10px;

}

.backend {

float: right; /* 浮动到右边 */

color: white;

text-decoration: none; /* 去除下划线 */

font-size: 16px;

margin-right: 12px;

margin-top: 10px;

}

.pub_info {

margin-top: 10px;

color: darkgray;

}

.menu {

margin-top: 20px;

}

文章详情页的样式——article_detail.css:

.article_info .title {

margin-bottom: 20px;

}

上述css代码是将标题部分和文字主体部分错开20像素。

2、构建点赞样式

根据博客园代码,在article_detail.html引入文章推荐踩灭:

{% extends "base.html" %}

{% block content %}

{ { article_obj.title }}

{ { article_obj.content|safe }}

{# 文章点赞 #}

1

0

{% endblock %}

将点赞的css样式写入article_detail.css中:

.article_info .title {

margin-bottom: 20px;

}

#div_digg {

float: right;

margin-bottom: 10px;

margin-right: 30px;

font-size: 12px;

width: 125px;

text-align: center;

margin-top: 10px;

}

/* 推荐 */

.diggit {

float: left;

width: 46px;

height: 52px;

background: url('/static/font/upup.gif') no-repeat;

text-align: center;

cursor: pointer;

margin-top: 2px;

padding-top: 5px;

}

/* 反对 */

.buryit {

float: right;

margin-left: 20px;

width: 4

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值