css – 自定义Tumblr的* new * Like Button iFrame {LikeButton}

栏目: CSS · 发布时间: 6年前

内容简介:来自tumblr {LikeButton}的新代码提供了很少的选项:颜色和大小.它注入一个iFrame,它处理“Like”功能并提供SVG图形.但是,由于iframe和跨站点脚本策略,不再可以使用css更改它,也不能编辑其内容.

来自tumblr {LikeButton}的新代码提供了很少的选项:颜色和大小.

它注入一个iFrame,它处理“Like”功能并提供SVG图形.

但是,由于iframe和跨站点脚本策略,不再可以使用css更改它,也不能编辑其内容.

如何修改或插入新代码,以使用我自己的Like按钮sprite或svgs?

造型Tumblr像按钮

可悲的是,正如OP所说,Tumblr之类的按钮具有最少的视觉选项,很难用CSS /javascript定位.所以是时候换个新主意……

想法

我们知道两件事:

我们自己的Like Button,在视觉上,应该是我们想要的.文字,图片,网页等

Tumblr Like按钮记录了一个点击,Tumblr在存储数据方面发挥了神奇作用.

如果我们可以在视觉上隐藏Tumblr Like按钮,然后将它放在我们自己的Like按钮上,我们就有了一个风格,工作的按钮!

主题标记

主题标记的示例,这里的关键是为两个Like Buttons都有一个包含元素,并确保Tumblr Like Button位于我们自己的Like Button之前,这样我们就可以利用css中相邻的兄弟选择器.

<div class="custom-like-button">
  {LikeButton}
  <span class="our_toggle">
    ♥
  </span>
</div>

呈现标记

渲染/实时代码的示例.主题运算符{LikeButton}现在是<div>与类.like_toggle.

<div class="custom-like-button">
  <div class="like_button">
     /* Iframe */
  </div>
  <span class="our_button">
    ♥
  </span>
</div>

CSS魔术

关键是将Tumblr Like按钮放在我们自己的按钮上方.

.custom-like-button {
  position: relative;
  display: block;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

/* class for the Tumblr Like Button iframe */
.like_button {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 10;
}
/* Force iframe to fill button */
.like_button iframe {
  width: 100% !important;
  height: 100% !important;
}
/* class for Our Like Button */
.our_button {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

田田!您现在应该拥有自己的Like按钮来注册用户!

您还可以在悬停时设置样式:

/* Hover State */
.like_button:hover + .our_button {
  color: red;
}

当用户注册了类似的内容时:

/* Liked State */
.like_button.liked + .our_button {
  background: red;
  color: white;
}

我希望有所帮助!如果你遇到困难我就离开了标记 here .

翻译自:https://stackoverflow.com/questions/21708662/customise-tumblrs-new-like-button-iframe-likebutton


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Data Structures and Algorithms in Python

Data Structures and Algorithms in Python

Michael T. Goodrich、Roberto Tamassia、Michael H. Goldwasser / John Wiley & Sons / 2013-7-5 / GBP 121.23

Based on the authors' market leading data structures books in Java and C++, this book offers a comprehensive, definitive introduction to data structures in Python by authoritative authors. Data Struct......一起来看看 《Data Structures and Algorithms in Python》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

随机密码生成器
随机密码生成器

多种字符组合密码

SHA 加密
SHA 加密

SHA 加密工具