An adaptive pure CSS approach can be found here:
http://jsfiddle.net/bennyaarup/5gyp6/
HTML
I add FB comment code blocks in duplicate - amounting to the number of adaptive stages (data-width) I need. I add the extra class = .fb-1
, .fb-2
, .fb-3
etc... which I need in the CSS.
<div class="fb-comments fb-1" data-href="http://yourdomain.com" data-width="900" data-numposts="5" data-colorscheme="light"></div>
<div class="fb-comments fb-2" data-href="http://yourdomain.com" data-width="800" data-numposts="5" data-colorscheme="light"></div>
<div class="fb-comments fb-3" data-href="http://yourdomain.com" data-width="700" data-numposts="5" data-colorscheme="light"></div>
<div class="fb-comments fb-4" data-href="http://yourdomain.com" data-width="600" data-numposts="5" data-colorscheme="light"></div>
<div class="fb-comments fb-5" data-href="http://yourdomain.com" data-width="500" data-numposts="5" data-colorscheme="light"></div>
<div class="fb-comments fb-6" data-href="http://yourdomain.com" data-width="400" data-numposts="5" data-colorscheme="light"></div>
<div class="fb-comments fb-7" data-href="http://yourdomain.com" data-width="300" data-numposts="5" data-colorscheme="light"></div>
<div class="fb-comments fb-8" data-href="http://yourdomain.com" data-width="200" data-numposts="5" data-colorscheme="light"></div>
CSS
I style the adaptive stages using media queries and display:none to show the respective comment field
@media all and (min-width: 400px), (max-width: 300px) {
.fb-8{
display: none !important;
}
}
@media all and (min-width: 500px), (max-width: 400px) {
.fb-7{
display: none !important;
}
}
@media all and (min-width: 600px), (max-width: 500px) {
.fb-6 {
display: none !important;
}
}
@media all and (min-width: 700px), (max-width: 600px) {
.fb-5 {
display: none !important;
}
}
@media all and (min-width: 800px), (max-width: 700px) {
.fb-4 {
display: none !important;
}
}
@media all and (min-width: 900px), (max-width: 800px){
.fb-3 {
display: none !important;
}
}
@media all and (min-width: 1000px), (max-width: 900px){
.fb-2 {
display: none !important;
}
}
@media all and (max-width: 1000px) {
.fb-1 {
display: none !important;
}
}
It's a bit of a hack, but it works beautifully
data-width="100%"
. I believe you would still need JS for it to play nicely with window resizes. developers.facebook.com/docs/plugins/comments – Exaggeration