Html 尽管多次尝试,仍无法在页面中心对齐脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16252728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
unable to allign script at center of page despite several attempts
提问by atari400
I am unable to place my ads at the center of my site www.ios7.me
我无法将我的广告放置在我网站的中心 www.ios7.me
this is the script:
这是脚本:
<script type="text/javascript">
ch_client = "verronica";
ch_width = 250;
ch_height = 250;
ch_type = "mpu";
ch_sid = "Chitika Default";
ch_color_site_link = "0000CC";
ch_color_title = "0000CC";
ch_color_border = "FFFFFF";
ch_color_text = "000000";
ch_color_bg = "FFFFFF";
</script>
<script src="http://scripts.chitika.net/eminimalls/amm.js" type="text/javascript">
</script>
I have tried various attempts like:
我尝试了各种尝试,例如:
<div align="center">
script
</div>
<center>
script
</center>
<td allign="center">
script
</td>
but all did not go so well Its all just alligned to left. I have run out of all clues as I am very poor in css
但一切都没有那么顺利这一切都只是向左对齐。我已经用完了所有的线索,因为我在 css 方面很差
回答by Dynamic Remo
Its simple, just assign some hard code WIDTH and apply MARGIN to AUTO to your DIV (which is wrapping your ADs). For Example:
它很简单,只需分配一些硬代码 WIDTH 并将 MARGIN 应用于 AUTO 到您的 DIV(它正在包装您的广告)。例如:
<div style="width:1024px; margin:auto;">
<!-- Your Ad related code here -->
</div>
or simply if you want to get width dynamicaly as soon as your page loads, then do let me know in your comment, i will surely get that done for you :)
或者只是如果您想在页面加载后立即获得宽度,请在评论中告诉我,我一定会为您完成:)
All the Best !
祝一切顺利 !
回答by M_Willett
The <center>
element is deprecated - see http://www.codehelp.co.uk/html/deprecated.html. Use CSS instead so, <p style="text-align:center;">script</p>
. Also try margin: auto;
该<center>
元素已弃用 - 请参阅http://www.codehelp.co.uk/html/deprecated.html。使用 CSS 代替,<p style="text-align:center;">script</p>
. 也试试margin: auto;
If you could show a live example (use something like http://jsfiddle.net/) that would really help as there are various dependancies that CSS relies on to work correctly.
如果你能展示一个活生生的例子(使用类似http://jsfiddle.net/ 的东西),这真的很有帮助,因为 CSS 依赖于各种依赖来正常工作。
Hope this helps
希望这可以帮助
回答by Samir Prajapati
i do this it works .... please try and check it
我这样做它有效......请尝试检查它
The element is deprecated - see http://www.codehelp.co.uk/html/deprecated.html. Use CSS instead so, script
该元素已弃用 - 请参阅http://www.codehelp.co.uk/html/deprecated.html。改用 CSS,脚本
. 也试试 margin: auto;If you could show a live example (use something like http://jsfiddle.net/) that would really help as there are various dependancies that CSS relies on to work correctly.
如果你能展示一个活生生的例子(使用类似http://jsfiddle.net/ 的东西),这真的很有帮助,因为 CSS 依赖于各种依赖来正常工作。