html - 与博客内容一起运行的粘性横幅

标签 html css wordpress

我正在尝试添加横幅广告以在我的博文左侧转换。

然而,到目前为止,我的尝试导致它出现在将博客文章内容推到页面下方的内容之上。

实时链接:https://www.moneynest.co.uk/pension-crisis-uk/

添加到头部:

<div id=”LeftFloatAds”><a href="https://www.pensionbee.com" target="_blank"><img src="https://www.moneynest.co.uk/wp-content/uploads/2018/12/160x600b.png" alt="PensionBee sidebar ad"></a></div>

添加到 CSS 中

@media only screen and (min-width: 1400px) and (max-width:500px) {
#LeftFloatAds{

left: 0px;

position: fixed;

text-align: center;

top: 200px;

}

}

仅供引用,我关注了 this guide .

最佳答案

  1. 首先,替换...的位置,将其移动到您的主要内容包装器中。
  2. 然后应用这个 css,

因为你只想在更宽的屏幕上显示它然后使用它,

@media only screen and (min-width: 1400px) {
    #LeftFloatAds {
        position: fixed;
        display: block;
        overflow: hidden;
        left: 0;
        top: 200px;
    }
}

这将在小于 1400 像素的屏幕上隐藏横幅。

@media only screen and (max-width: 1399px) {
    #LeftFloatAds {
        display: none;
    }
}

关于html - 与博客内容一起运行的粘性横幅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54028789/

相关文章:

javascript - 如何处理 "click"事件,即使元素从 mousedown 和 mouseup 之间的光标下方移动?

html - 图像在 safari 中打破圆形边框

javascript - 对 DOM 事件监听器感到困惑

c# - 如何制作网页渐变 ASP.NET 和 CSS?

wordpress - 如何使用引导网格映射图像数组?

html - 如何固定使用导航栏和 div 标签

html - 垂直对齐 : middle an <img> inside a div doesn't centers image

jquery - 需要根据 CheckBox 选中状态在切换 DiV 中设置 CssClass

php - Custruct正确的查询: WP_Term_Query with child_of,深度和meta_query

jquery - wp_register_script 具有与协议(protocol)无关的源参数