绝对将所有内容放在网站上? [英] Absolutely positioning everything on a website?

查看:110
本文介绍了绝对将所有内容放在网站上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和某人讨论了绝对定位。他声称,最佳做法是确保大多数浏览器的所有内容都相同,并且这是维护您打算用于网站的外观的最简单方法。



我不同意他的意见,绝对定位将是网页布局的一种补救方法,也是一种整体上最佳的选择。



在我看来,我更加热衷关于使用边距/宽度/仔细的浮动调整的方法,有时使用表格。当然,这只是一个小小的概括,我不会停止使用绝对定位,只是因为我会在意识形态上反对它,只是我发现一种绝对位置法则适合所有方法,就像我的同僚所主张的那样。



对此有什么普遍共识?

解决方案

互联网不是可打印的,我认为绝对定位所有内容并不是理想的选择。我认为您可以通过使用您的方法来确保外观看起来更好,或者通过使用EM来增加宽度,以使页面在不同的屏幕尺寸(和DPI)上更加流畅。这样一来,您的内容可以更好地扩展,并且随着移动浏览的流行,这一点很重要。以适应不同的设备,而不是像您在印刷品中那样强制采用100%像素完美的布局。那不是互联网的本质。



编辑:仔细考虑一下,使用所有绝对值可能会再次吸引您使用移动设备浏览器,如果您不小心的话。如果您的网站在iPhone之类的位置上使用绝对定位(假设您将某些元素对齐到角落)会发生什么?该位置将与iPhone的角落对齐,这是一个奇数比率(与计算机相比),并且分辨率要小得多;丢掉一切。如果您使用了floats / widths / etc等组合,请确保网站保持其原始大小,并且只需要滚动即可。


I had a discussion with someone about absolute positioning. He claims that the best practice to secure that everything looks all the same across most browsers and that it's the easiest way to maintain the looks and feel that you intended for a website.

I disagreed with his opinion, that absolute positioning would be the remedy and an overall best approach to laying out a webpage.

In my case, I've been more keen on using the approach of margin/width/careful floating adjustments, and sometimes the occasional table. Which is a slight generalization, as of course, I wouldn't stop using absolute positioning just because I'd be ideologically against it, it's just that I find the approach absolute-position one rule fits all-approach as advocated by my peer to be rather doubtful.

What's the general consensus about this?

解决方案

The internet isn't print, I don't think it's ideal to absolutely position everything. I'd argue you can make sure things look better by using your method, perhaps augmented by using EMs for some widths to allow the page to be a bit more fluid on different screen sizes (and DPIs). This allows your content to scale better, and with mobile browsing becoming more popular that's important.

In my experience pages tend to look better overall when you plan for your page to have to adapt a bit to different devices, as opposed to trying to force 100% pixel-perfect layouts like you'd see in print. That's just not the nature of the internet.

Edit: Thinking about it more, using all absolutes might really come back to bite you with mobile browsers if you're not careful. What happens when your site uses absolute positioning on something like the iPhone (assuming you're aligning some elements to corners)? The positioning would be aligned to the iPhone's corners, which are an odd ratio (compared to computers) and much smaller resolution; throwing everything out of wack. If you used a combination of floats/widths/etc you'd make sure the site kept its original size and you'd just have to scroll.

这篇关于绝对将所有内容放在网站上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆