删除html / css中的元素之间的空格(离子)

时间:2017-04-25 14:44:13

标签: html css ionic-framework

我试图以离子方式去除这两个元素之间的空白区域。

这是HTML:

class Program
    {
        static void Main(string[] args)
        {
            IHubProxy _hub;
            var url = @"http://localhost:8080/";
            var connection = new HubConnection(url);
            _hub = connection.CreateHubProxy("TestHub");
            connection.Start().Wait(); // *this is where I get the error

            string line = null;
            while ((line = System.Console.ReadLine()) != null)
            {
                _hub.Invoke("DetermineLength", line).Wait();
            }
            _hub.On("ReceiveLegth", x => Console.WriteLine(x));
        }
    }

这是css:

<link rel="StyleSheet" type="text/css" href="./css/style.css" />
<ion-view name="tab-suppliers">
  <ion-content>

    <h2 class="no-padding bg-lightblue font-white tb-header"><center>TITLE!</center></h2>

    <div class="row text-center bg-lightblue font-white test">
      <div class="col col-25">
        TEST
      </div>
      <div class="col col-25">
        TEST
      </div>
      <div class="col col-25">
        TEST
      </div>
      <div class="col col-25">
        TEST
      </div>
    </div>
  </ion-content>
</ion-view>

Ain&test .test类应该删除元素之间的空白区域?如果没有,有人可以解释我为什么吗?

这样做的正确方法是什么?

提前致谢。

2 个答案:

答案 0 :(得分:1)

<h2>元素的默认bottom-margin会导致<h2><div>之间的空格。所以你必须删除这个边际。请参阅以下示例:

.bg-lightblue {
  background-color: #99CEFF;
}
.text-center {
  text-align: center;
}
.font-white {
  color: white;
}
.tb-header {
  width: 100%;
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
}
h2 {
  margin-bottom: 0px;
}
<ion-view name="tab-suppliers">
  <ion-content>
    <h2 class="no-padding bg-lightblue font-white tb-header"><center>TITLE!</center></h2>
    <div class="row text-center bg-lightblue font-white test">
      <div class="col col-25">
        TEST
      </div>
      <div class="col col-25">
        TEST
      </div>
      <div class="col col-25">
        TEST
      </div>
      <div class="col col-25">
        TEST
      </div>
    </div>
  </ion-content>
</ion-view>

答案 1 :(得分:0)

尝试:

h2 {
  margin-bottom: 0;
}

/* should target any .row immediately proceeded by an <h2> */
h2 ~ .row {
  padding-top: 0;
}