简体   繁体   English

使Facebook页面插件具有响应性(在各处搜索并且找不到解决方案)

[英]Make Facebook page plugin responsive (Searched everywhere and couldn't find a solution)

It appears that Facebook has decided to change the like box to page plugin, and limit the maximum size to 500px. 看来Facebook已决定将“喜欢”框更改为页面插件,并将最大尺寸限制为500px。

Page with the script: http://akecheta.com/facebooklikeplugin-responsive.html 带有脚本的页面: http : //akecheta.com/facebooklikeplugin-sensitive.html

My problem is exactly that one, I can't use a full width layout on the likebox. 我的问题恰恰是我不能在likebox上使用全角布局。 Here is what I've tried so far: 到目前为止,这是我尝试过的:

 /* Fits the like box to the parent div, creating a fluid layout */
#u_0_0 > div {
  width: 100% !important;
}
/* Fits the background image to the like box */
.uiScaledImageContainer._2zfr {
  width: 100% !important;
}

/* Modifies the first background color of the fans part */
._h7l {
  background: #EE6C00 !important;
}
/* Modifies the second background color of the fans part */
._h7n {
  background: transparent !important;
}
/* Modifies the color of the text above the fans thumbnails */
/* Modifies the color of the text above the fans thumbnails */
._50f3 {
  font-size: 150%;
  line-height: 25px;
  color: #FFFFFF !important;
}

It worked amazingly well on the fly, but then I saved those changes to my stylesheet, nothing happened. 它的运行非常出色,但是后来我将这些更改保存到样式表中,没有任何反应。

All the classes are changed when the page loads, but the id #u_0_0 is still kept the same. 页面加载时,所有类都将更改,但ID #u_0_0仍保持不变。 It's as if it didn't exist. 好像它不存在。

Right now I'm trying to think of a solution for this problem, as I need to use the page plugin with a full width layout. 现在,我正在尝试解决此问题的方法,因为我需要使用具有全宽布局的页面插件。

The reason your CSS worked when you did it on the fly in devtools and not when you put it in your stylesheet is that the iframe the plugin is being loaded in cannot be styled by CSS outside of it. 当您在devtools中动态执行CSS而不是将其放入样式表时,之所以能使CSS工作,是因为无法在CSS外部对要加载插件的iframe进行样式设置。 The only way to style an iframe is from within the iframe itself. 设置iframe样式的唯一方法是从iframe本身内部。 Since you are loading this as a third party plugin, you will need to look for a way to dynamically inject the styles into the iframe once it has fully loaded. 由于您是将其作为第三方插件加载的,因此您需要寻找一种在iframe完全加载后将样式动态注入iframe的方法。

See this question for a bit more direction in what you are trying to do: Append a stylesheet to an iframe with jQuery 请参阅此问题,以了解您要执行的操作的更多方向: 使用jQuery将样式表附加到iframe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM