问题
I'm using the comments facebook social plugin When I embed it, the script created an iFrame that has the text "Facebook social plugin" with the facebook logo at the bottom (as seen in the image attached below).
I inspected the element using Firebug and tried to set its class to display:none; in my CSS file. However - that does not hide it (I suspect it's because it's in its own iFrame). How can I use CSS or jQuery (or any other method) to disable that text?
Thanks!
回答1:
You're overcomplicating things. Small CSS change...
.fb_iframe_widget{overflow: hidden;}
.fb_ltr{margin-bottom: -20px;}
Done!
Sidenote - I agree with the warning about legal issues. You shouldn't really do this.
回答2:
You can only control the options given to you by the plugin developer (here, Facebook). Most plugin developers do not allow altering their code and Facebook is one of them. I suggest you stick to what Facebook provides you.
Have a read of the following:
- Brand Permissions Center
- Facebook Platform Policies
回答3:
If it's a CSS issue for the iFrame then you can't do anything about it (eg: overide it). It is loading from another site so you don't have control over it.
回答4:
I ran into this issue as well. I fixed it by setting the height of the iframe using an inline style and set overflow to hidden.
Example: iframe is 185px. Add this inline:
style="overflow:hidden; height:160px;"
回答5:
See the iframe example in the description of the .contents() method.
You can easily access the DIV (or whatever) and modify the CSS for it, or manipulate any other way.
回答6:
.fb_iframe_widget {overflow: hidden;}
div.fb-comments.fb_iframe_widget span {margin-bottom: -35px;}
回答7:
Css
.facebookOuter { width:248px; padding:10px 0px 10px 10px; height:230px; overflow:hidden; } .facebookInner { height:250px; width: 238px; overflow: hidden; }
And Like Box
<div class="facebookOuter"> <div class="facebookInner"> <div class="fb-like-box" data-width="250" data-height="300" data-href="http://www.facebook.com/myhumourbook" data-border-color="dodgerblue" data-show-faces="true" data-stream="false" show_border=false data-header="false"> </div> </div> </div> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script>
回答8:
If you play around with the box's dimensions, you can sort of make it disappear on it's own, and you haven't even technically broken their terms, because you haven't modified their code using your own hacks. =)
Example:
The dimensions on this one are 310x382. You can still see it poking it's head up, but essentially it's hidden enough that anyone just glancing over your page won't really notice it much. And since most surfers tend to speed read ...
回答9:
I used the following code to get rid of it. It seems to be the most up to date one that is working. Just change the margin-bottom to your liking.
.fb_iframe_widget {
overflow: hidden;
}
.fb_iframe_widget span {
margin-bottom: -30px;
}
回答10:
The other solutions have the side effect of pushing things down. Here's a Less/Sass/SCSS solution that accounts for the pull down:
div.fb_iframe_widget span {
overflow: hidden;
margin-top: -32px;
iframe {
top: 32px;
}
}
They've set the iframe to position: absolute, presumably to reduce your chances of pulling this off. That makes top easy to set, and voila.
They also set their iframe to overflow: hidden, so you can attack that with a shorter style if you prefer, and just end up with a larger gap at bottom of the comments box:
div.fb_iframe_widget iframe {
box-sizing: border-box;
padding-bottom: 32px;
}
Chomp.
来源:https://stackoverflow.com/questions/4870082/how-to-remove-the-facebook-social-plugin-text