【问题标题】:How do I center an embeded iTunes button?如何使嵌入式 iTunes 按钮居中?
【发布时间】:2015-12-06 03:40:46
【问题描述】:

我正在尝试将这个 iTunes 按钮嵌入到一个网站上,但它似乎会自动向左点亮。我将在此代码中的何处以及如何使按钮居中?请参阅下面的示例代码。谢谢!

<a href="https://geo.itunes.apple.com/us/album/believe-in-love-single/id993882452?app=itunes" style="display:inline-block;overflow:hidden;background:url(http://linkmaker.itunes.apple.com/images/badges/en-us/badge_itunes-lrg.svg) no-repeat;width:165px;height:40px;"></a>

【问题讨论】:

  • 您可以访问 .css 和 html 吗?

标签: button alignment center itunes


【解决方案1】:

如果您可以访问 css,那么这里有一个快速修复,您可以使用 flex box 轻松完成此操作。

包装你的锚标签:

<div class="itunes">
    <a href="https://geo.itunes.apple.com/us/album/believe-in-love-single/id993882452?app=itunes" style="display:inline-block;overflow:hidden;background:url(http://linkmaker.itunes.apple.com/images/badges/en-us/badge_itunes-lrg.svg) no-repeat;width:165px;height:40px;"></a>
</div>

添加这个css

.itunes {
    display:flex;
    justify-content:center;

}

jsFiddle

虽然不赞成添加内联样式...,但如果您在紧要关头,这也可以。除非您必须这样做,否则请不要这样做:

<div style="display:flex;justify-content:center;">
<a href="https://geo.itunes.apple.com/us/album/believe-in-love-single/id993882452?app=itunes" style="display:inline-block;overflow:hidden;background:url(http://linkmaker.itunes.apple.com/images/badges/en-us/badge_itunes-lrg.svg) no-repeat;width:165px;height:40px;"></a>
</div>

注意:弹性框适用于大多数浏览器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-27
    • 2019-09-11
    • 2018-02-08
    • 1970-01-01
    • 2021-07-03
    • 2014-08-04
    • 2013-09-13
    • 2020-10-26
    相关资源
    最近更新 更多