【问题标题】:resizing social links with media queries通过媒体查询调整社交链接的大小
【发布时间】:2017-02-28 19:21:06
【问题描述】:

我遇到了一些困难。我正在开发一个网站,并且在减小屏幕尺寸时遇到社交链接图标变小的问题。我想使用媒体查询来指定较小屏幕的大小 - 我正在尝试的方法不起作用。

页面顶部的社交链接:

 `<div class="container">
    <div class="row-1">
        <!--First column-->
        <div class="col-sm-3">
            <img src="images/fbGrey.png" class="img-responsive" 
style="width:50px" alt="Find us on Facebook">
                <hr class="vertical"/>

        </div>
<!--Second column-->
<div class="col-sm-3">
    <img src="images/twitterGrey.png" class="img-responsive" 
style="width:50px" alt="Follow us on Twitter">
        <hr class="vertical"/>

        </div>
<!--Third column-->
<div class="col-sm-3">
    <img src="images/instagramGrey.png" class="img-responsive" 
style="width:50px" alt="Follow us on Instagram">
        <hr class="vertical"/>

        </div>
<!--Fourth column-->
<div class="col-sm-3">
    <img src="images/pinterestGrey.png" class="img-responsive" 
style="width:50px" alt="Follow us on Pinterest">
        <hr class="vertical"/>
        </div>
    </div>
</div>`

页脚中的社交链接: `

        <!--First column-->
        <div class="col-md-3">
 <!--Social buttons-->
        <!--First column-->
    <div class="container">
      <div class="row-3">
        <div class="col-sm-3">
            <img src="images/fbGrey.png" class="img-responsive" 
style="width:70px" alt="Find us on Facebook" id="fb">
    <img src="images/twitterGrey.png" class="img-responsive" 
style="width:70px" alt="Follow us on Twitter">

    <img src="images/instagramGrey.png" class="img-responsive" 
style="width:70px" alt="Follow us on Instagram">

    <img src="images/pinterestGrey.png" class="img-responsive" 
style="width:70px" alt="Follow us on Pinterest">

    </div>
</div>
</div>`

此外,当屏幕尺寸减小时,在页脚内<div class="footer-copyright"> 的高度会增加——有人知道为什么会这样吗?我也想使用媒体查询来解决这个问题,但它似乎不起作用。

 `<!--footer-->
  <div class="span4">
    <!-- empty, but using spacer to prevent collapse -->
     <div class="spacer10"></div>
    </div>            </div>

        <!--Second column-->
        <div class="col-md-3">
            <h5 class="title">OUR SERVICES</h5>
                <p><a href="treatments.html">Treatments</a></p>
                <p><a href="bookings.html">Bookings</a></p>
                <p><a href="shop.html">Shop</a></p>
            </div>

        <!--First column-->
        <div class="col-md-3">
            <h5 class="title">COMPANY</h5>
                <p><a href=index.html>Home</a></p>
                <p><a href="contact.html">Location</a></p>
                <p><a href="contact.html">Contact</a></p>
                <p><a href="privacypolicy.html">Privacy Policy</a></p>

        </div>
            <!--Second column-->
        <div class="col-md-3">
            <h5 class="title">CONTACT</h5>
                <strong>Hands on Sports & Holistic Therapy</strong><br>
                50 Westonfields<br>
                Bridgetown<br>
                Totnes<br>
                TQ90 5QX<br>
                <abbr title="Phone">P: 07450232531</abbr><br><br>
            </address>

            <address>
                <strong>Email: </strong><br>
                <a href="mailto:#">jo@handson-therapy.com</a>
            </address>
        </div>
    </div>
</div>

<hr>
 <!--Copyright-->
<div class="container">
<div class="row-5">
    <div class="col-sm-12">
        <div class="footer-copyright">
            <div class="container-fluid">
                <center>© 2017 Copyright: Hands on Sports & Holistic 
Therapy. All rights reserved.</center>   
            </div>
        </div>
    </div>
</div>
<div class="span4">
    <!-- empty, but using spacer to prevent collapse -->
     <div class="spacer40"></div>
    </div>

</footer>
<!--/.Footer-->`

这是我在 JSFiddle 中的代码 - 观察到没有图像。 https://jsfiddle.net/AnnieWebDev/frrvmpnr/

感谢您的帮助:)

【问题讨论】:

  • 没有指向您的 jsfiddle 的链接。还请在问题中包含代码。
  • 哇,这太快了——我一发布并添加链接就意识到了。

标签: html css media-queries


【解决方案1】:

您是否尝试过设置 min-width: 70px !important;在 img 标签上。这样图像就不会比您在其中设置的值小。

【讨论】:

  • 它们应该在列表中还是在整个页面中。因为我认为设置 col-xs-3 是针对较小的屏幕尺寸的,因为 col-sm-3 看起来像是拉伸了整个宽度
  • 它们应该在页脚的列表中,并在页面顶部水平放置。那么我应该使用哪个? “xs、sm、md、lg”?他们扩大规模 - 所以我应该使用 xs 吗?
  • 通常都在同一列上使用,因此它们会根据屏幕大小而变化。您应该仔细查看引导程序,因为他们在文档getbootstrap.com/css 中对此进行了解释
  • 现在已经解决了社交图标的问题,我从row 中删除了值并将所有图标放在一个额外的列中,并使用偏移量将它们保持在大屏幕和中屏幕的右侧.我以前无法让偏移量工作 - 因此 CSS。
【解决方案2】:

您的代码中有几个错误。在此处输入您的代码并点击检查,然后修复错误。 html validator

&lt;/link&gt; 去掉&lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"&gt;&lt;/link&gt; 的末尾

&lt;center&gt; 已过时,请使用 css。在您的 css 样式表中,您可以添加 h1 { text-align: center;} 或内联 html 这样做 &lt;h1 style="text-align:center;"&gt;Centered Heading&lt;/h1&gt;

【讨论】:

  • 谢谢 - 我已经做出了这些更改和其他建议。不过还是有问题:(
【解决方案3】:

尝试在你的head 标签中添加这个:

<meta name="viewport" content="width=device-width, initial-scale=1">

【讨论】:

  • 谢谢 - 似乎没有任何区别。
  • 您的测试页是否存在于任何地方?发布指向它的链接,或更新您的 JS Fiddle 并再次发布该链接。
  • Annie 在 html 中你没有 但你有结束 。把它放在 然后在你所有的图像行上取出 \ 并使用 /
猜你喜欢
  • 2022-12-09
  • 1970-01-01
  • 2022-01-04
  • 2020-03-04
  • 2014-02-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-03
相关资源
最近更新 更多