简体   繁体   English

在所有分辨率的两个图标之间添加空格

[英]Add space between the two icons for all resolutions

I have one static row with two icons ion-email and ion-compose . 我有一个静态行,带有两个图标ion-emailion-compose

In my demo there is no space between the icons. 在我的演示中,图标之间没有空格。 I need to add some but it must work for all resolutions. 我需要添加一些,但它必须适用于所有分辨率。

<div class="list">

  <a class="item item-icon-right" href="#">
    <i class="icon ion-email"></i>
    <i class="icon ion-compose"></i>
    Check mail
  </a>
      </div>

I need to add constant space between the two icons. 我需要在两个图标之间添加恒定的空间。

Here is my code: http://codepen.io/anon/pen/aOzOWZ 这是我的代码: http : //codepen.io/anon/pen/aOzOWZ

You need to acheive these changes - codepen 您需要实现这些更改-Codepen

.item-icon-right i.icon {
  display: inline-block;
  float: right;
  position: relative;
  right: auto;
}

This will result in the following css, notice the commented out parts: 这将导致以下CSS,请注意注释掉的部分:

.item-icon-right .icon {
  /* right: 11px; */
  display: inline-block;
  float: right;
}
.item-icon-left .icon, .item-icon-right .icon {
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  -moz-align-items: center;
  align-items: center;
  /* position: absolute; */
  /* top: 0; */
  height: 100%;
  font-size: 32px;
}

A very simple solution would be to statically position the first icon. 一个非常简单的解决方案是静态放置第一个图标。

Simply add this class to your CSS. 只需将此类添加到CSS。

.item-icon-right i:nth-child(1) {
  right: 50px;
}

For a more robust solution, I would suggesting creating styles for a separate component that can be floated to the right and will contain inline icons. 对于更强大的解决方案,我建议为一个单独的组件创建样式,该样式可以浮动到右侧并包含嵌入式图标。

.icon-holder-right {
  float: right;
}

For example: http://codepen.io/anon/pen/MwYwqw 例如: http : //codepen.io/anon/pen/MwYwqw

The benefit of this approach is that you won't overwrite any existing rules, meaning it's not likely to break any other parts of your app. 这种方法的好处是您不会覆盖任何现有规则,这意味着它不太可能破坏应用程序的任何其他部分。

Try this 尝试这个

 .icon{ position:inherit !important; display:inline-block !important; float:right; } 

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

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