我想删除 HTML 空白
我有一个困扰我的新问题...
我正在制作一个网页,我希望在不滚动的情况下修复该网页,最重要的是我希望我的主 Div 填充aaaaaaaa所有我的可用空间...
我编写了这段代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <title>There is a @#!¤*-ing blank !</title> <style type='text/css'> html {margin:0px;padding:0px;height:100%;overflow:hidden;border: 3px solid green} div {margin:0px;padding:0px;} </style> </head>
正如你所看到的,即使我的 body 填充和 div 边距设置为 0,我的 body 元素边框和 div 元素边框之间也有一个空白...
我曾经读过“More Eric Meyer on CSS”,其中包含一个解决方案这个问题但那是很久以前的事了,我不记得了......
任何帮助将不胜感激^^。
I have a new problem that bugs me ...
I am making a web page that I want to be fixed with no scrolling and most important I want my main Div to fill aaaaaaaaall my available space...
I made this code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>There is a @#!¤*-ing blank !</title>
<style type='text/css'>
html {margin:0px;padding:0px;height:100%;overflow:hidden;border: 3px solid green}
div {margin:0px;padding:0px;}
</style>
</head>
<body onload="document.getElementById('mydiv').style.height=document.getElementsByTagName('html')[0].offsetHeight+'px'"><div id="mydiv" style="margin:0px;padding:0px;width:100%;border: 2px solid red"></div></body>
</html>
As you can see I get a white space between my body element border and my div element border even though my body padding and div margin are set to 0...
I had once read "More Eric Meyer on CSS" that contains a solution to this issue but it was a long time ago and I don't remember ...
Any help would be greatly appreciated ^^.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您没有设置正文的样式:
You didn't set the body's style:
你的正文边距没有设置为 0px,只是 html 的设置。
Your body margin isn't set to 0px, just that of html.
将 body 标记上的边距设置为 0。
Set the margin to 0 on the body tag.
另外,不要
在每个选择器中添加:,而是在 CSS 文件顶部全局添加:
In addition - rather than adding:
to every selector do it globally at the top of your CSS file: