【问题标题】:Center an ad on the header在标题上居中放置广告
【发布时间】:2015-03-08 16:13:58
【问题描述】:

我在将广告置于标题中心时遇到了一些与 CSS 相关的问题,如您所见 你向下滚动,广告不在中间,看起来很奇怪。

请记住,该网站是响应式的,适用于所有屏幕 而我现在的解决方案只能在移动设备上运行良好,而不能在 PC 上运行。

我希望你能帮我把它放在中心。

查看问题的链接:My Website

【问题讨论】:

  • 什么不居中?
  • 尝试使用 position:absolute margin: 25px auto 10px; min-height: 100px; display: inline-block; position: absolute; left: 50%; transform: translatex(-50%);
  • 页眉上的广告没有居中。
  • @Vitorino-Fernandes 您的代码只有在较小的设备和较小的屏幕尺寸下所有标题部分由于某种原因变得更小时才能正常工作,有什么想法吗?
  • 您希望标题高度相同,然后您可以为.top提供固定高度

标签: html css center


【解决方案1】:

添加这将centermiddle中的广告

className{
  margin: 35px auto 10px;
  min-height: 100px;
  display: inline-block;
  position: absolute;
  left: 50%;
  transform: translatex(-50%);
}

【讨论】:

    【解决方案2】:
    .your_ad {
        position:absolute;
        left:50%;
        margin-left:-half of your ad_width;
    }
    .your_header {position:relative;}
    

    【讨论】:

      猜你喜欢
      • 2020-06-24
      • 2013-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-18
      • 2023-03-21
      相关资源
      最近更新 更多