css - margin 不适用于 ionic 中的 h2 元素

标签 css

<ion-view>
<ion-content class="has-header padding coloredBackground">



<h2 class="centerHeading"> Receive your Order by:  </h2>
</ion-content>


</ion-view>

CSS:

.centerHeading{
    text-align: center;
    color: #6E6E6E;
    margin-top:20px;

}

margin-top 或 margin 根本不起作用。我该如何解决这个问题?

演示:http://play.ionic.io/app/6d960c043467

最佳答案

你的 margin-top 被 ionic.min.css 覆盖了-

因为,在你的 ionic.min.css 文件中,

h2:first-child{
  margin-top:0px;
}

解决方案一:

要么在样式表中用你自己的 css 覆盖 h2 的 css 样式,方法如下

h2:first-child{
  margin-top:20px;
}

解决方案 2:

.centerHeading{
    text-align: center;
    color: #6E6E6E;
    margin-top:20px !important;
}

这里是解释“!important”的链接,Click Here

关于css - margin 不适用于 ionic 中的 h2 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32397723/

相关文章:

css - 如何包装 UL 列表 - 使用 css 将 LIs 换行

javascript - 如何使用 jQuery 在 IE 中附加样式表?

javascript - 有什么方法可以通过 Javascript 或 CSS 更改浏览器打印设置

css - 使用 CSS 并排显示带有图像的元素

jquery - 在页面卸载/浏览器关闭之前运行动画

javascript - 在悬停 css 上隐藏一个不是直接子元素的元素

css - 使一个 div 跨越网格中的两行

css - 创建 CSS 覆盖防止在 IE 中点击下方

jquery - 隐藏的 div 在页面加载时出现几分之一秒

css - 在轮播图片下方显示轮播标题