简体   繁体   English

将按钮与文本对齐(垂直和水平)

[英]Align an pin it button with text (both vertically & horizontally)

I am stumped and am hoping for a bit of help. 我很难过,希望得到一些帮助。

I'd like to align a Pin It Button with some text, with enough space between the two so it looks nice. 我想将Pin It Button与一些文本对齐,两者之间有足够的空间,所以看起来不错。 Then I'd like to have horizontal and vertical lines surrounding the button and text. 然后我想在按钮和文本周围有水平和垂直线条。

In a previous question someone helped me with the code in fiddle .. although when I transfer it to my website , it isn't working 在之前的一个问题中,有人用小提琴中的代码帮助我..虽然当我将它转移到我的网站时 ,它无法正常工作

Thanks so much in advance, Alison 非常感谢Alison

Code: 码:

<div class="recipesharing">
<div>

<a href="https://www.pinterest.com/pin/create/button/" data-pin-do="buttonBookmark" data-pin-tall="true" data-pin-round="true" data-pin-save="false"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_round_red_32.png" /></a><p.id>Pin For Later</p.id>
</div>
</div>

CSS CSS

div.recipesharing {
    border-bottom: 2px solid rgb(247, 247, 247);
   border-top: 2px solid rgb(247, 247, 247);
   width: 600px;
   height: 60px;
}

div.pintherecipe {
  display: inline-block;
}

p.id {
    display: inline;
    padding-right: 100px;
    line-height:150px;
}

img {vertical-align: middle;margin-right:5px;}

This has nothing to do with jQuery. 这与jQuery无关。

Anyway, the code on JSFiddle differs from the one at the site. 无论如何,JSFiddle上的代码与站点上的代码不同。

JSFiddle: 的jsfiddle:

<div class="recipesharing">
  <div>
  <a href="https://www.pinterest.com/pin/create/button/" data-pin-do="buttonBookmark" data-pin-tall="true" data-pin-round="true" data-pin-save="false">
    <img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_round_red_32.png" />
  </a>
  <p.id>Pin For Later</p.id>
  </div>
</div>

Website: 网站:

<div class="recipesharing">
  <div>
    <p>
      <span class="PIN_1467591127309_button_pin PIN_1467591127309_round PIN_1467591127309_tall" data-pin-log="button_pinit_bookmarklet" data-pin-href="https://www.pinterest.com/pin/create/button/"></span>
      Pin For Later
    </p>
  </div>
</div>

This is not all, though. 但这并不是全部。 This isn't valid: 这是无效的:

<p.id>Pin For Later</p.id>

I'm sure you actually meant (judging by your CSS code): 我确定你的意思是(根据你的CSS代码判断):

<p class="id">Pin For Later</p>

Also, I removed "line-height: 150px," because it messed with the design. 另外,我删除了“line-height:150px”,因为它与设计混淆了。

This is how it looked after I had changed the code at the site to the one at JSFiddle (the corrected one): [screenshot link] . 这就是我将网站上的代码更改为JSFiddle(修正后的代码)的代码: [screenshot link] The only difference between it and the example at JSFiddle seems to be the font, which is easy to fix (if you even want a sans-serif font at the website). 它和JSFiddle的例子之间的唯一区别似乎是字体,这很容易修复(如果你甚至想在网站上使用无衬线字体)。

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

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