简体   繁体   English

twitter按钮在twitter-bootstrap导航栏中的位置

[英]position of twitter button in twitter-bootstrap navbar

this is the main page of my blog http://www.lowcoupling.com it is a tumblr blog based on twitter bootstrap as you can see I have just placed the twitter button in the right side of the nav bar just after the google plus button. 这是我的博客的主页http://www.lowcoupling.com这是一个基于twitter引导的tumblr博客,您可以看到我刚刚将twitter按钮放在导航栏的右侧,紧跟在google plus之后按钮。 I can't see why, when the button is loaded related script, it is placed at the top of the bar and not at the same height of the plus button. 我不明白为什么,当按钮加载相关脚本时,它放置在栏的顶部而不是加号按钮的相同高度。

There are some styles applied by bootstrap on nav>a elements. 引导程序在nav> a元素上应用了一些样式。 The resulting google+ label is inside a link tag. 产生的google +标签位于链接标记内。 The other one is not. 另一个不是。 One quick solution is to include the script of the second label (twitter) inside a link tag. 一种快速的解决方案是将第二个标签(twitter)的脚本包含在链接标签中。

<li><a>  <---

<a href="https://twitter.com/lowcoupling" class="twitter-follow-button" data-show-count="true" data-show-screen-name="false">Follow @lowcoupling</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

</a></li>  <----

UPDATE The scripts doesn't consider the link tag as a container so the above won't work. 更新脚本不将链接标记视为容器,因此上述内容不起作用。 A hack that would work is to give your li tag, <li style="padding: 14px 15px;"></li> . 可行的破解方法是为您的li标签提供<li style="padding: 14px 15px;"></li> But the best you could do is to check the nav>a styles in bootstrap css and copy those on a class of your own, which you will give it to a container of the iframe. 但是最好的办法是在bootstrap css中检查nav> a样式并将其复制到您自己的类中,然后将其提供给iframe的容器。

I just had this annoying issue also. 我也有这个烦人的问题。 I fixed it by giving my anchor an ID and then using jQuery to move the Twitter rendered stuff into my anchor: 我通过给锚定ID来解决它,然后使用jQuery将Twitter呈现的内容移动到锚定中:

<ul class="nav navbar-nav navbar-right">
    <!-- Note the ID I put on the link -->
    <li><a href="#" id="twitter-fix">
        <a href="https://twitter.com/Whatever" class="twitter-follow-button" data-show-count="false">Follow @Whatever</a>
        <script>
            !function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https'; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = p + '://platform.twitter.com/widgets.js'; fjs.parentNode.insertBefore(js, fjs); } }(document, 'script', 'twitter-wjs');
            // Custom fix here
            $(".nav .twitter-follow-button").detach().appendTo("#twitter-fix");
        </script>
    </a></li>
    <li><a href="#">Other link</a></li>
</ul>

My solution was simpler - add a line above the twitter button, and set the height using font-size. 我的解决方案更简单-在twitter按钮上方添加一行,并使用font-size设置高度。 This was the code in my style.css: 这是我的style.css中的代码:

#twitter-fix {
  font-size: 7px;
}

And this was inside my navbar (note the br tag): 这是在我的导航栏中(请注意br标签):

<ul class="nav navbar-nav navbar-right">
  <li id="twitter-fix"><br>
  <a href="https://twitter.com/UserName" class="twitter-follow-button"
  data-size="large" data-show-count="false">Follow @UserName</a>
  <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
  </li>
</ul>

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

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