0

我这里有这个设计:

在此处输入图像描述

你可以看到材料图标有点太接近描述了。我认为我可以通过执行以下操作在两者之间创建一些填充:

.location-secondary-info span:first-child {
  padding-right: 5px;
}

那是无效的。

这是组件代码:

renderLocation() {
    const filteredLocations = this.props.locations.filter(location => {
      return !location.name.match(/[A-Z0-9]+$/);
    });

    return filteredLocations.map(location => {
      if (location.airport_code) {
        return (
          <div key={location.id}>
            <div className="location">
              <h1>
                {location.name} ({location.airport_code})
              </h1>
              <div className="location-secondary-info">
                <span>
                  <i className="material-icons">airplanemode_active</i>
                  {location.description}
                </span>
              </div>
            </div>
          </div>
        );
      } else {
        return (
          <div key={location.id}>
            <div className="location">
              <h1>{location.name}</h1>
              <div className="location-secondary-info">
                <span>
                  <i className="material-icons">location_city</i>
                  {location.description}
                </span>
              </div>
            </div>
          </div>
        );
      }
    });
  }
4

1 回答 1

3

您应该选择i跨度内的元素,因此:

.location-secondary-info span i {
  padding-right: 5px;
}

随着span:first-child您选择span内部的第一个元素.location-secondary

于 2019-04-03T13:59:35.577 回答