CSS Align="center" 对显示 gridview 行的数据的影响

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1593305/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:10:25  来源:igfitidea点击:

Align= "center" effect on data shown gridview rows

cssasp.netgridviewalignment

提问by Madi D.

I am facing a weird situation, I am developing an asp.net website, and I added a gridview control, it is placed inside td tag.

我面临一个奇怪的情况,我正在开发一个asp.net网站,我添加了一个gridview控件,它被放置在td标签内。

When I ran the website online, I noticed that the data shown on the rows are shifted to the left while their header tags are centered, so I gave the td an align="center"property, trying to make the data show centered in each column, and that worked perfectly when debugging the site offline.

当我在线运行网站时,我注意到行上显示的数据向左移动,而它们的标题标签居中,所以我给了 td 一个align="center"属性,试图让数据显示在每列的中心,并且有效离线调试站点时完美。

However, when I ran the site online (after upload), the data still showed shifted (or aligned left).

但是,当我在线运行网站时(上传后),数据仍然显示偏移(或左对齐)。

Am I missing something here?

我在这里错过了什么吗?

回答by Muhammad Akhtar

Try this:

尝试这个:

<RowStyle HorizontalAlign="Center" />
<AlternatingRowStyle HorizontalAlign="Center" />

回答by Himadri

Set this property in the gridview: RowStyle-HorizontalAlign="Center"

在 gridview 中设置此属性: RowStyle-HorizontalAlign="Center"

回答by Heinzi

Have a look at the HTML source in your browser. If you see the align="center" in the offline but not in the online version, something went wrong when publishing your web page (or your browser cache needs to be cleaned, see Crimson's answer).

在浏览器中查看 HTML 源代码。如果您在离线版本中看到 align="center" 而在在线版本中没有看到,则在发布您的网页时出现问题(或者您的浏览器缓存需要清理,请参阅 Crimson 的回答)。

回答by Kshitij Saxena -KJ-

1) Do an MD5 of the uploaded files to see if the upload did go through correctly

1) 对上传的文件做 MD5 以查看上传是否正确通过

and,

和,

2) Refresh your browser's cache

2) 刷新浏览器缓存