代码之家  ›  专栏  ›  技术社区  ›  MK-DK

用图像替换字体图标

  •  0
  • MK-DK  · 技术社区  · 7 年前

    我正在为我所在地区的汽车修理厂写一页公司地址。

    Demosite

    img src 标记,但图片在文本上方。

    改变现状的最佳方法是什么?目前我有大约30个地址,所以我把HTML缩短到只有一行。

    字体图标是用这个CSS类设置的:

    #content .card .block-1:before{ content: "\f1b9"; }

    jsfiddle可以是 seen here

    HTML格式:

    <section id="content">
      <div class="container-fluid">
        <!-- Row 1 -->
        <div class="row mt-5">
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 col-xl-4">
            <div class="card">
              <div class="card-block block-1">
                <h3 class="card-title">Lorem Ipsum 1</h3>
                <p class="card-text">
                  Adress 1<br/>
                  1234 Postcode<br/>
                  Tlf: <a href="tel:+9012345678">+90 12 34 56 78</a><br/>
                </p>
                <a href="#" title="Vis vej" target="_blank">Show direction<i class="fa fa-angle-double-right ml-2"></i></a>
              </div>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 col-xl-4">
            <div class="card">
              <div class="card-block block-1">
                <h3 class="card-title">Lorem Ipsum 2</h3>
                <p class="card-text">
                  Adress 2<br/>
                  1234 Postcode<br/>
                  Tlf: <a href="tel:+9012345678">+90 12 34 56 78</a><br/>
                </p>
                <a href="#" title="Vis vej" target="_blank">Show direction<i class="fa fa-angle-double-right ml-2"></i></a>
              </div>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 col-xl-4">
            <div class="card">
              <div class="card-block block-1">
                <h3 class="card-title">Lorem Ipsum 3</h3>
                <p class="card-text">
                  Adress 3<br/>
                  1234 Postcode<br/>
                  Tlf: <a href="tel:+9012345678">+90 12 34 56 78</a><br/>
                </p>
                <a href="#" title="Vis vej" target="_blank">Show direction<i class="fa fa-angle-double-right ml-2"></i></a>
              </div>
            </div>
          </div>
        </div>
      </div>  
    </section>
    
    2 回复  |  直到 7 年前
        1
  •  2
  •   jwebb    7 年前

    在CSS中设置图标所在的背景图像:

    #content .card .block-1:before {
        content: " ";
        background: url(http://placekitten.com/50/50);
        width: 50px;
        height: 50px;
    }
    
        2
  •  2
  •   K H    7 年前

    #content .card .block-1:before { 
         content:url('http://yourdomain.net/example.png');
         width: 50px;
         height: auto;
    }