删除 css 位置的空间:相对
我有一个链接和一个并排的 iframe。我希望链接出现在 iframe 上。这发生在 td 元素内部。该模式在几行上迭代。当我使用相对 css 定位时,我可以在 iframe 上显示链接,但链接所在的空间仍然会出现。并且它不必要地增加了列的高度。我想消除这个空间。我该怎么做?
I have a link and an iframe side-by-side. I want the link to appear over the iframe. This occurs inside of a td element. this pattern is iterated over a few rows. When I use relative css positioning, I am able to display the link over the iframe, but the space the link would have been in, still appears. and it add unnecessarily to the column height. I want to eliminate this space. How can I do this?
I looked at this but it seems that this solution would still jack up the tr/td height. I also have a sample of my issue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
折叠行高应该可以做到。确保输入一个测量值,而不仅仅是“0”,这样它才能在 ie6 中工作。我将
.collapse
类添加到包含锚点的div
中。 http://jsfiddle.net/grs53/20/HTML
CSS
Collapsing the lineheight should do it. Be sure to put a measurement, and not just "0" so it will work in ie6. I added the
.collapse
class to thediv
s containing the anchors. http://jsfiddle.net/grs53/20/HTML
CSS
将 HTML 更改为此
将 CSS 更改为:
相对位置对象保持其初始位置,但显示在其他位置。绝对定位的元素实际上被移动到新位置。您可以将绝对定位的元素移动到相对定位的顶部。
在上面的示例中,我创建了一个相对定位的 div,其中任何绝对位置元素都可以从相对定位元素的左上角移动。如果相对定位的元素移动到页面上的任何其他位置,绝对定位的元素也会随之移动。
Change your HTML to this
And you CSS to this:
A relative position object keeps it's initial placement but is displayed elsewhere. An absolute positioned element is actually moved to a new position. You can move absolute positioned elements on top of relative positioned.
In the example above I created a div that is relative positioned in which any absolute position element can be moved around from of the top left corner of the relative positioned element. If the relative positioned element is moved anywhere else on the page the absolute one will follow.
该不需要的空间来自您包裹在链接周围的 DIV 元素。删除它。
http://jsfiddle.net/saad/grs53/12/
That unwanted space is from the DIV element you have wrapped around you link. Remove that.
http://jsfiddle.net/saad/grs53/12/
只需折叠保存链接的
(例如将高度设置为0)。跨浏览器可能需要额外的样式,但这里是在 Chrome 中测试的示例
Just collapse the
<div />
that holds the link (e.g. set height to 0). Cross browser might require additional styles but here is an example tested in Chrome