HTML和CSS,位置绝对问题
将所有网站内容放在具有以下样式的 div 中是否良好且可取?
<div style="position:absolute; top:0; left:0; width:100%;">
ALL site content come here
</div>
我的问题是我想在站点 div 中的某些地方放置宽度为 100% 两侧没有空格,所以如果我将所有网站内容放在一个绝对 div 中 并放置一个 100% 宽度的普通 div,它将从一侧到另一侧,两侧没有空格 例如:
<div style="width:100%;background-color:yellow;"></div>
那么,这样做好吗?途中是否遇到一些困难?
Is it good and desirable to put all the web site content in a div with the following styling?
<div style="position:absolute; top:0; left:0; width:100%;">
ALL site content come here
</div>
My problem is that i want to put in some places in the site divs that the width will be
100% without the spaces in the sides , so if i put all the site content in one absolutely div
and put a normal div with 100% width it will be from side to side without the spaces in the sides
example :
<div style="width:100%;background-color:yellow;"></div>
so , is that good to do that? and if it get some difficulties on the way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您的建议是安全的,但是您可以通过将
style="margin:0"
添加到您的来实现您想要的效果。或者,如果您有
.css
文件,则只需向其中添加body{margin:0}
即可。我认为这会更简单,但是我不确定我是否正确理解你的问题。I think what you are suggesting is safe, but you may accomplish what you want by adding
style="margin:0"
to your<body>
. Or if you have a.css
file, you can just addbody{margin:0}
to it. It would be simpler I think, but then, I am not sure whether I understand your question correctly.