页面缩小,如何让内容全部居中?
网络上大部分的网站,都可以实现页面缩小之后内容居中。例如csdn也可以。
我希望我自己的站也可以啊 我自己开发的站,缩小之后,内容全部往左上角靠拢,好纠结,我要跟主流一样啊。请问CSS该如何设计?或者哪个CSs标签可以实现?或者什么方法可以实现跟csdn这个功能,请各位指点。~~
回复讨论(解决方案)
那是因为你的页面默认是居左的,与缩小没关。
参考下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title> New Document </title> <style type="text/css"> body{ text-align:center; } .main{ width:1024px; height:1024px; background:#FF0000; margin:0px auto 0px auto; } </style> </head> <body> <div class="main"></div> </body></html>
定义margin:0 auto;可以实现左右居中
楼上正解 将div设置margin:0 auto;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

Especially over the past decade, mobile devices have become the primary way to share content with friends and family. The easy-to-access, easy-to-use interface and ability to capture images and videos in real time make it a great choice for creating and sharing content. However, it's easy for malicious users to abuse these tools to forward unwanted, sensitive content that may not be suitable for viewing and does not require your consent. To prevent this from happening, a new feature with "Sensitive Content Warning" was introduced in iOS17. Let's take a look at it and how to use it on your iPhone. What is the new Sensitive Content Warning and how does it work? As mentioned above, Sensitive Content Warning is a new privacy and security feature designed to help prevent users from viewing sensitive content, including iPhone

How to change the page that opens the Microsoft Edge browser to 360 navigation? It is actually very simple, so now I will share with you the method of changing the page that opens the Microsoft Edge browser to 360 navigation. Friends in need can take a look. I hope Can help everyone. Open the Microsoft Edge browser. We see a page like the one below. Click the three-dot icon in the upper right corner. Click "Settings." Click "On startup" in the left column of the settings page. Click on the three points shown in the picture in the right column (do not click "Open New Tab"), then click Edit and change the URL to "0" (or other meaningless numbers). Then click "Save". Next, select "

HTML, CSS and jQuery: Techniques for implementing image zoom-in and zoom-out effects, specific code examples are required. With the development of the Internet, the design of web pages pays more and more attention to user experience. Among them, pictures, as one of the important elements of web design, can often bring users an intuitive and rich visual experience. The special effect of zooming in and out of images can enhance users' perception and interaction with web content, so it is widely used in web design. This article will introduce how to use HTML, CSS and jQuery to achieve special effects of zooming in and out of images, and provide

Users feel that the search box that comes with win10 is too big in the taskbar and is very annoying. They ask how to reduce the search box size in win10. Generally, you just need to turn it into an icon to reduce the size. Let’s take a look at how to reduce the size of the search box in win10 in detail. Tutorial. How to reduce the size of the search box in Windows 10: 1. Right-click the taskbar and multiple functions will pop up. 2. Find the search function item in it. 3. Turn on the search function, and we choose to display the search icon (W) to zoom out. 4. After setting it up, it will become a reduced version of the icon, as shown below.

Page refresh is very common in our daily network use. When we visit a web page, we sometimes encounter some problems, such as the web page not loading or displaying abnormally, etc. At this time, we usually choose to refresh the page to solve the problem, so how to refresh the page quickly? Let’s discuss the shortcut keys for page refresh. The page refresh shortcut key is a method to quickly refresh the current web page through keyboard operations. In different operating systems and browsers, the shortcut keys for page refresh may be different. Below we use the common W

Standby is a new feature in the iOS 17 update that provides a new and enhanced way to access information when your phone is idle quickly. With StandBy, you can conveniently check the time, view upcoming events, browse your calendar, get weather updates for your location, and more. Once activated, the iPhone will intuitively enter standby mode when set to landscape while charging. This feature is perfect for wireless charging points like your bedside table, or when you're away from your iPhone charging during daily tasks. It allows you to swipe through various widgets displayed in standby to access different sets of information from various applications. However, you may want to modify these widgets or even delete some based on your preferences and the information you need frequently. So let's dive into

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of
