【问题标题】:Buttons responsive with the background image响应背景图像的按钮
【发布时间】:2020-08-16 03:38:04
【问题描述】:

现在我在 Magento 2 中工作。当我在 google chrome 中调整大小时,我遇到了一个问题,即带有按钮的背景图像不会保持不变。

.botones1 {
    position: absolute;
    left: 400px;
    font-size: 22px;
    color: white;
    text-decoration: none;
    font-weight: bold;
    background-color: #357b2b !important;
}

.botones1:hover {
    background-color: #9FCD4C !important;
}

.botones2{
    position: absolute;
    left: 796px;
    font-size: 22px;
    color: white;
    text-decoration: none;
    font-weight: bold;
    background-color: #357b2b !important;
}

.botones2:hover {
    background-color: #9FCD4C !important;
}
<div class="container">
    <img src="https://placeimg.com/1000/480/any" alt="Smiley face">
        <a class="button botones1" href="#">Buy Coupon</a> 
        <a class="button botones2" href="#">Sell Coupon</a>
</div>

当我使用移动设备进入时,我想要背景图像,并且按钮以响应方式调整大小,我希望它们保持在同一个位置。

谢谢。

【问题讨论】:

    标签: css image button background responsive


    【解决方案1】:

    如果你想让你的页面响应,你应该使用 Flexbox 和 Grid 来定位你的元素而不是像素,因为它们会极大地限制你。您可以尝试将 display:flex 用于 &lt;div&gt; 并将您的元素排列在 flex 容器中(尝试使用 Inspector)。

    这里有一些关于 flexbox 的好东西: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

    网格: https://css-tricks.com/snippets/css/complete-guide-grid/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多