简体   繁体   English

从导入的图标列表图像更改渲染的图标大小

[英]Change rendered icon size from imported icon list image

I need to find a way to change the size of some icons i have in a single image file and are being rendered by a script module inside Visual Composer addon from Wordpress. 我需要找到一种方法来更改我在单个图像文件中拥有的某些图标的大小,这些图标由Wordpress的Visual Composer插件中的脚本模块呈现。

Example html code: 示例html代码:

<ul class="ts-social-icons simple">
<li style="margin: 5px;  padding: 0px;" class="ts-social-icon  center">
    <a href="mailto:BLABLA@gmail.com" class="ts-social-email " target="_blank" style="">
        <i style="top: 9px;" class="ts-social-email"></i>
    </a>
</li>
<li style="margin: 5px;  padding: 0px;" class="ts-social-icon  center">
    <a onclick="return false" "="" href="#" class="ts-social-phone " target="_blank" style="">
        <i "="" 9px;="" top:="" class="ts-social-phone style="></i>
    </a>
</li>
<li style="margin: 5px;  padding: 0px;" class="ts-social-icon  center">
    <a onclick="return false" "="" href="#" class="ts-social-cell " target="_blank" style="">
        <i "="" top:="" class="ts-social-cell style="></i>
    </a>
</li>
<li style="margin: 5px;  padding: 0px;" class="ts-social-icon  center">
    <a href="http://www.asd.com/" class="ts-social-portfolio " target="_blank" style="">
        <i style="top: 9px; " class="ts-social-portfolio"></i>
    </a>
</li>
<li style="margin: 5px;  padding: 0px;" class="ts-social-icon  center">
    <a href="http://www.asd.com/" class="ts-social-link " target="_blank" style="">
        <i style="top: 9px; " class="ts-social-link"></i>
    </a>
</li>
<li style="margin: 5px;  padding: 0px;" class="ts-social-icon  center">
    <a href="http://https://www.facebook.com/asd" class="ts-social-facebook " target="_blank" style="">
        <i style="top: 9px; " class="ts-social-facebook"></i>
    </a>
</li>

Current CSS 当前的CSS

.ts-social-icons li a i {
  background: url("images/team-socials-black.png") no-repeat scroll center center rgba(0, 0, 0, 0) !important;
}

If i change the height or width here all i get are repeated icons: 如果我在这里更改高度或宽度,我得到的都是重复的图标:

.ts-logo-icons li a i, .ts-social-icons li a i, .ts-teammate-icons li a i {
  display: inline-block;
  height: 20px;
  margin: 10px auto;
  text-align: center;
  text-decoration: none;
  width: 20px;
  z-index: 999;
}

maybe there is a way to do it with Javascript or jquery instead of CSS? 也许有一种方法可以用Javascript或jquery代替CSS?

I don't suggest you do this with a splice, as don't have the control you want without extensively writing code that uses numeric calculations to resize the div when the user resizes the page. 我不建议您使用接头来执行此操作,因为如果用户在调整页面大小时,没有大量编写使用数字计算来调整div大小的代码,就没有想要的控件。

Instead, I would use one of the following ways: 相反,我将使用以下方式之一:

First Way: 第一种方式:

Use an img element instead: 请改用img元素:

<img width="100%" height="100%"/>

Then it will always resize to it's parent div (currently 20px) 然后它将始终调整为其父div的大小(当前为20px)


Second Way: 第二种方式:

Use a background-image (like you already are, but not a splice), and add this: 使用background-image (就像您已经是background-image一样,而不是拼接图像),并添加以下内容:

background-size:100% 100%;

Now that you see how it's done with a single image, imagine how difficult it would be to do a splice. 现在您了解了如何处理单个图像,想象一下进行拼接有多么困难。 But if you did want to go this route, you will need to use the 2nd way, just change it to px coordinates instead of % and change them when the page resizes (w/ something like jQuery) 但是,如果您确实想走这条路线,则需要使用第二种方法,只需将其更改为px坐标而不是% ,然后在页面调整大小时更改它们(带有jQuery之类的东西)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM