search

Home  >  Q&A  >  body text

javascript - How to insert an advertisement at the top of the page without destroying the page layout (without affecting the content below)?

is a long advertisement at the top, pushing down other content. Directly inserting a p img will not work, as it will cause the underlying content to be misaligned or cover up. Can it be solved using js/jquery?

我想大声告诉你我想大声告诉你2726 days ago1082

reply all(4)I'll reply

  • 三叔

    三叔2017-07-05 10:42:45

    Wrap it with a p

    <p><img src="xxx" /></p>

    reply
    0
  • 高洛峰

    高洛峰2017-07-05 10:42:45

    Generally, advertisements on web pages are a piece of js code. It is easier to place ads in this way. The function of the js code is to request materials, create dom elements, adjust the layout, and handle the display and click logic. If the line is troublesome, you can directly set an iframe.

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-07-05 10:42:45

    If the ad space is 100% wide and 200px high

    body{
        margin-top : 200px;
    }
    
    .banner{
        position : fixed;
        width:100%;
        height:200px;
        top:0;
        left:0;
    }

    reply
    0
  • 黄舟

    黄舟2017-07-05 10:42:45

    To prevent the content below from being misaligned or covered, you can just create a translucent overlay advertisement. Use pointer-events:none and apply pointer-events:none to the translucent overlay element. The content behind the translucent overlay can be seen. Get it, you can also perform click events
    For details, please refer to the master
    http://www.zhangxinxu.com/stu...

    reply
    0
  • Cancelreply