【问题标题】:Social Icons in Center when in Mobile and to Right when in Desktop社交图标在移动设备中位于中心,在桌面设备中位于右侧
【发布时间】:2015-07-31 16:04:59
【问题描述】:

我正在尝试组织我的社交图标,以便当网站在移动设备中时,图标位于 Div 的中心。当站点在桌面时,图标应位于 Div 的右侧。

我的问题:目前图标只是向左对齐,然后在移动设备中居中。我不能让它向右而不是向左对齐。

HTML 代码:

    <div class="soimg">
        <div class="images">
            <img src="social/facebook.png"/>
            <img src="social/insta.png"/>
            <img src="social/twitter.png"/>
            <img src="social/youtube.png"/>
        </div>
    </div>



CSS: 


    .soimg img {
        height:30px;
        width: auto;
        margin-right: 5px;
        display: inline-block;
        filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%);
        opacity: 0.4;

        text-align: right;
    }

    .soimg img:hover {
        filter: none;
        -webkit-filter: grayscale(0%);
        opacity: 1;
    }

    .images {
        height:50px;
        background-color:#1c1c1c;
        margin-top: -20px;
        margin-bottom: -20px;
    }  
    @media screen and (max-width:700px) {
        .soimg {
            margin-left: auto;
            margin-right: auto;
            text-align: center;
        }
    }

【问题讨论】:

  • 您遇到了什么问题?
  • @KevinBoucher 目前它只向左对齐,然后在移动设备中移动到中心 - 我想要右而不是左

标签: html css image twitter-bootstrap icons


【解决方案1】:

您需要指定text-align:right。这不是默认值。

.soimg {
    text-align: right;
}

【讨论】:

  • 这不符合我的要求 - 它将其永久定位在右侧
  • 如果您将媒体查询放在该分配之后并覆盖它,则不会。
  • @RandomMath 是正确的。 Here 是一个 jsfiddle,它显示了实际的样式。更改框架的大小以查看文本对齐更改。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-18
  • 1970-01-01
  • 1970-01-01
  • 2015-08-21
  • 2018-12-04
  • 1970-01-01
  • 2019-09-30
相关资源
最近更新 更多