2012-03-08 21 views
0

我正在使用像發送,推特和谷歌加這樣的Facebook。我爲facebook div指定寬度320,爲tweet指定寬度105。但臉書和推文按鈕的 (div/iframe)應根據其內容寬度自動增加和減少。有人可以建議我一種方法來實現這一點。我的主要想法是減少這些部分之間的差距。指定Facebook像發送div,鳴叫iframe,Google Plus動態寬度

<script type="text/javascript"> 
    var SnImpl= "<%=SnImpl%>"; 

    if (SnImpl == "true") { 
     (document, 'script', 'facebook-jssdk'); 
     (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')); 
     (function() { 
      var scrGooglePlus = document.createElement('script'); 
      scrGooglePlus.type = 'text/javascript'; 
      scrGooglePlus.async = true; 
      scrGooglePlus.src = 'https://apis.google.com/js/plusone.js'; 
      var scrWriter = document.getElementsByTagName('script')[0]; 
      scrWriter.parentNode.insertBefore(scrGooglePlus, scrWriter); 
     })(); 
    } 

<div class="fb-like" data-href="<%=strSNURL %>" data-send="true" 
     data-width="320px" data-show-faces="false"> 
    </div> 
    <iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitter.com/widgets/tweet_button.html?url=<%=strSNURL %>&via=SomeOne&text=Something" style="width: 105px; height: 25px;"></iframe> 
    <g:plusone href="<%=strSNURL %>"></g:plusone> 

回答

0

你需要知道前面的時間有多寬,使插件。

如果您爲Facebook指定320px,則Facebook的iFrame將變爲320px。 Facebook甚至不知道iframe的內容需要多少最小寬度,所以它只是遵循320px的訂單。 (http://developers.facebook.com/docs/reference/plugins/like/)我會建議嘗試指定120px,並將佈局樣式更改爲「button_count」,因爲與默認的「標準相比,此樣式相當窄」。 「box_count」將是它們全部最窄的選項,只佔50px寬度。

對於twitter(https://dev.twitter.com/docs/tweet-button),您可以爲count屬性指定「vertical」,並將其寬度限制爲58px。

對於谷歌(https://developers.google.com/+/plugins/+1button/),您可以指定高泡以匹配其他兩個。這會給你50px的寬度。