Html 调整页面大小/放大/缩小页面时,div会四处移动
我知道这个问题已经被问了很多次了,但我发现没有一个解决方案对我有效。我有我正在制作的这个网站,当我放大和缩小网页时,div元素会四处移动。以下是HTML代码:Html 调整页面大小/放大/缩小页面时,div会四处移动,html,css,resize,Html,Css,Resize,我知道这个问题已经被问了很多次了,但我发现没有一个解决方案对我有效。我有我正在制作的这个网站,当我放大和缩小网页时,div元素会四处移动。以下是HTML代码: <!doctype html> <html> <head> <!-- Header --> <center> <img src="http://i1349.photobucket.com/albums/
<!doctype html>
<html>
<head>
<!-- Header -->
<center>
<img src="http://i1349.photobucket.com/albums/p742/lucasgame13/header_zps8f446598.png" alt="Shawn&LucasWeb">
</center>
<!-- Header -->
<title>Shawn & Lucas Web Development!</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<center>
<h1>Welcome to Shawn & Lucas Web Development!</h1>
</center>
<!-- Left Box -->
<div id="leftbox">
<h3> Info </h3>
<p>This is a test. -</p>
<p>- <a href="Red.html">Click here!</a>
</p>
</div>
<!-- End of Left Box -->
<!-- Middle Box -->
<div id="box">
<h3> Menu </h3>
<p>Navigate around the website!</p>
<center><a href="about.html">About Us</a>
</center>
</div>
<!-- End of Middle Box -->
<!-- Right Box -->
<div id="rightbox">
<h3> Menu </h3>
<p>Navigate around the website!</p>
</div>
<!-- End of Right Box -->
<footer>
<p class="us"><font color="black"> Shawn & Lucas WEB - Custom Websites © </p>
</footer>
</body>
</html>
我没有链接,因为它只在我的电脑上,但我有截图:
-这是100%缩放的正常网站
-这就是放大时的效果
我不能发布超过2个链接,因为我没有10个声誉,但当它被缩小时
这些箱子彼此相隔很远
我知道这个网站不是一个很好的网站,但它只是一个测试,因为当我放大时,没有任何其他网站可以工作。请帮忙!(我试过一个包装器,但没用)你误用了绝对定位。经验法则:你需要绝对定位吗?没有 因此,使用浮点:
float: left;
width: 33%;
请记住使宽度适当,这样它就不会落在下一行。如果您不想费心考虑填充/边框,请使用以下选项:
box-sizing: border-box;
-moz-box-sizing: border-box;
它使边框在宽度范围内(而不仅仅是内容)。如果使用
文本对齐:居中
在框周围添加包装,并将显示:内联块
添加到框中,它们将在中间彼此相邻对齐
HTML
你不应该在
标记中放置图像,而
标记已被弃用。这很奇怪。我一直听说在缩放时东西会断裂,但我自己从来没有遇到过问题…@Mathias,我知道,是我的朋友(我们一起创建了这个网站)这样做的,我没有改变它,因为我没有注意到它。我修正了,但仍然不起作用。#bjb568我认为这与定位有关,但我真的不知道。@Lucas我认为可能是绝对/固定定位…
box-sizing: border-box;
-moz-box-sizing: border-box;
<div class="boxes">
<div class="box">Content</div>
<div class="box">Content</div>
<div class="box">Content</div>
</div>
.boxes {
text-align: center;
}
/* All the boxes */
.box {
vertical-align: top;
margin: 0 10px;
text-align: left;
display: inline-block;
}