是否可以将已经添加前缀的网页居中?

发布于 2025-01-06 00:03:49 字数 251 浏览 3 评论 0原文

无论如何,是否有办法将已经具有固定值的网页整体居中?我个人不会这么认为,但我花了很多时间制作一个我满意的布局,现在为了使其居中,一切都必须重写。有什么办法可以防止并集中预先编写的代码吗?像桌子一样?抱歉,如果这是一个对代码来说相当陌生的未受过教育的问题。

任何指导或方向都会很棒

这就是我所追求的,目前全部固定在左侧:

在此处输入图像描述

Is there anyway to overall centre a webpage that already has fixed values? I personally wouldn't have thought so, but I've spent a lot of time making a layout I'm happy with and now to centre it, it's all going to have to be rewritten. Is there any way at all to in case and centre pre-written code? Like a table? Sorry, if this is an uneducated question pretty new to code.

Any guidance or direction would be great

This what I'm after, which is currently all fixed to the left:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蛮可爱 2025-01-13 00:03:49

您可以尝试将其放入固定宽度且左右边距设置为自动的包装器中:

#wrapper {
    width: 700px;
    margin:0 auto;
}

<div id="wrapper">
  <!-- your content goes here -->
</div>

You could try putting it inside a wrapper with a fixed width and left and right margins set to auto:

#wrapper {
    width: 700px;
    margin:0 auto;
}

<div id="wrapper">
  <!-- your content goes here -->
</div>
小帐篷 2025-01-13 00:03:49

JQuery Position UI 库具有将任何元素居中的方法(http://jqueryui.com/demos/position/)。您可以在文档加载后调用它们。例如:

$(document).ready(function() {
     $( "#myTable" ).position({
          of: $( window ),
          my: "center",
          at: "center"});
});

JQuery Position UI library has methods to center any element (http://jqueryui.com/demos/position/). You can call them after the document loads. For example:

$(document).ready(function() {
     $( "#myTable" ).position({
          of: $( window ),
          my: "center",
          at: "center"});
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文