基于流体/百分比的布局上的图像未对齐
我有这个代码: http://jsfiddle.net/VV9qJ/ 但由于某种原因我似乎无法修复由图像引起的小像素错误。基本上,您会注意到一些图像周围有一个或两个像素的白色间隙,而另一些则没有,特别是当您调整浏览器窗口大小时。每个浏览器呈现的白色间隙也略有不同。
我的布局不能有任何间隙,所有内容必须相互紧密结合,包括浏览器窗口。
是否有一种万无一失的方法可以确保图像在不同浏览器中始终保持紧密接触?也许是 jQuery?我已经进行了大量的谷歌搜索,但没有发现任何相关内容。
仍然没有找到解决这个问题的方法。我很难相信没有解决方案,任何人都可以提供帮助吗?
I have this code: http://jsfiddle.net/VV9qJ/ but for some reason I cannot seem to fix the little pixel errors caused by the images. Basically you'll notice that some of the images have a pixel or two white gap around some of them whilst some do not, especially when you resize the browser window. Each browser renders the white gaps slightly differently as well.
My layout must not have any gaps and all content must be tight up against each other, including the browser window.
Is there a fool-proof method of ensuring the images remain tight up against one another at all times across different browsers? jQuery perhaps? I've done loads of Googling but found nothing on this.
Still haven't found a fix for this. I find it hard to believe that a solution isn't out there, can anyone help at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除非我不明白出了什么问题,否则我似乎无法重现白色间隙的问题,但听起来可能是边距或填充问题。
您可能还需要将 .smallLink 内的 img 标签的边距和填充设置为 0。
Unless I'm not understanding what's wrong, I can't seem to reproduce the problem with the white gaps, but it sounds like it could be a margin or padding problem.
You might also have to set margin and padding on img tags within .smallLink to 0.
在 groupoflink div
letter-spacing 下添加以下代码:-4px;
http://jsfiddle.net/VV9qJ/11/
Add following code under your groupoflink div
letter-spacing: -4px;
http://jsfiddle.net/VV9qJ/11/
您的问题是
content
类的 div 上的width:100%
..而带有
banner
类的 div 也设置为 < code>100% 宽度占据了完整的100%
空间,但是当您将 100% 细分为50% + 50%
时,会发生以下情况:划分100% 宽度比如说 - 500 到 250 + 250 对于你的子划分。但是只有当其父级(因为它是动态的)所采用的宽度是偶数
时,划分才能正确发生。即,2( n) ..否则,50%的划分不会正确发生,比如501是可用空间,这意味着100%宽度的div将占据完整的空间,即501 -- 但是宽度为 50% 的子 div 将得到
250px
和250px
留下您注意到的 1px 间隙!
background-color
这样你就可以忽略爬升的1px
空白!!这不是克服这个问题的最佳方法——应该有一种我现在无法想到的CSS方式..所以,这是一个JS解决方案..
即,Parent——如果501和第一个孩子有50%将为 250,因此第二个子级将为 501-250 + "px"
仅编辑了 1 组 HTML(您应该对其余部分执行相同操作)- 更改为获取父级的 id( 15 其 501)和大林(如果是 501 - 这将是 250)
还没有测试过它..希望它有效..
Your problem is the
width:100%
on the div with the classcontent
..while the div bearing the class
banner
is also set to100%
width occupies the complete100%
of the space,but when your subdividing the 100% into50% + 50%
what's happening is that its dividing the 100% width say - 500 into 250 + 250 for you sub divisions.But the division happens properly only when the width taken by its parent( since its dynamic) is anEVEN NUMBER
.. i.e, 2(n) ..else,the 50% division doesnt happen properly,say 501 was the space available which means the div's with 100% width will take up the complete space which is 501 -- but the child div's with 50% width will get
250px
and250px
leaving behind that `1px gap that your noticing!!..To remove the white space give a
background-color
so that you can overlook the1px
white space that creeps up!!This isnt the best method to overcome this -- there should be a css way which i'm unable to think of right now.. so,here's a JS solution..
i.e,Parent -- if 501 and the 1st child with 50% will be 250 hence the second child will be 501-250 + "px"
Edited only 1 set of your HTML ( you should do the same for the rest ) -- changed to get the id of the parent( 15 its 501 ) and the largelin ( if its 501 - this would be 250 )
Havnt tested it.. hope it works..