Centre align leaderboard ad

六眼飞鱼酱① 提交于 2019-12-25 10:57:20

问题


Struggling a little to centrally align a leaderboard ad on Dots & Dashes – positions itself correctly on certain pages, and incorrectly on several others, by the seems of it.

Have applied the <div class="center">AD CODE</div> tag, although that doesn't seem to have done the trick...

Any advice would be greatly appreciated, as per always! Thanks.


回答1:


Do you mean center horizontally or vertically?

To center horizontally you can add the following to the top of the page (within the <head></head> section):

<style type="text/css">
    .center {
        text-align:center;
    }
</style>

The above will control the class that you assigned (center) and adds text-align:center; to it.

If you are looking to center the div vertically, please post a JSFiddle




回答2:


To center something horizontally within the DIV use the following code...

<style type="text/css">
    .center {
        text-align:center;
    }
</style>

But to center something horizontally within the WINDOW and DIV, try this....

<style type="text/css">
    .center {
        text-align: center;
        margin: 0 auto;
    }
</style>


来源:https://stackoverflow.com/questions/24315140/centre-align-leaderboard-ad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!