问题标签 [margin]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
92044 浏览

html - 使用 z-index 在 Div 之上的 Div

我的 HTML 中有以下 div:

它直接在我的体内。

使用以下 CSS:

基本上,我有一个显示背景图像的 Div,我将在此之上有另一个具有透明度的 Div。此当前代码有效,但我的问题是当我试图从顶部取下内容 div 时。

例如,当我添加margin-top:100px时,也会降低图像。我认为如果它不在同一个 z-index 上,它不会碰它?为什么添加边距也会迫使 bgimage div 向下?

我也尝试过将内容类的 div 设置为绝对位置和 zindex,但这不会居中。我应该如何解决这个问题?

0 投票
7 回答
11860 浏览

safari - CSS: Chrome and Safari seem to 'add' border to width, while IE, Firefox & Opera don't

I'm trying to achieve cross-browser consistency for my website.

It's about this page: http://www[insert-dot-here]geld[insert-dash-here]surfen[insert-dot-here]nl/uitbetalingen.html (please note that I prefer this URL not to be made crawlable for seo-bots)

If you view this page in IE, Firefox or Opera, everything is fine, but in Chrome and Safari the tables are a little out of line (as you'll probably clearly notice).

What seems to be the problem?

It appears to me that in Chrome and Safari the left and right border (2px) in total are added to the set table width, while in the other browsers the border is considered part of the width.

The (most) relevant CSS-lines are the following ones (from the table.css file, also available through the page's source file):

So basically I have used a table-structure to organize images, like this: (the class of the table is uitbetaling)

If, here, I set the width of table.uitbetaling and table.uitbetaling img, table.uitbetaling td to the same value (e.g. both 496 or 498), the "problem" in Chrome and Safari is solved, however in Firefox the right side border is than blank. Because the right-side border can't "fit" in anymore. img and td must be at least 2px more narrow than table.uitbetaling for the right-border be visible in Firefox.

Is there any way to solve this?

0 投票
5 回答
16633 浏览

vim - 如何增加vim中行号边距的间距?

我在 vim 中的配色方案有问题:

替代文字
(来源:tinygrab.com

行号太接近代码。如何增加行号右边距的宽度?

0 投票
3 回答
107 浏览

css - 简单的 CSS 高度问题

我正在尝试创建一个基本布局,但我无法让它自动调整高度。DIV 容器出了点问题,因为它没有正确地将填充添加到顶部和底部元素。它应该是最高块的大小,现在是菜单块。

有任何想法吗? 网站

0 投票
6 回答
11544 浏览

css - Body Margin:0,Div Width:FF 和 Chrome 中的 100% 问题,在 IE 中很好

我开始把头发从头上拔下来...

我有以下内容:

这适用于 IE 生成一个漂亮的 div,100% 宽度,没有 H 滚动条...

现在在 Chrome 和 FF 中,它比窗口宽 1px,导致 H 滚动条......

这是为什么?我应该改用什么?

非常感谢!阿尔伯特

编辑:

我添加了 div { margin: 0; } 到头部并删除了 width: 100% 并且它起作用了,谢谢。

0 投票
3 回答
369 浏览

html - 浮动元素不包含在父元素中,导致底部边距问题

对,所以我有一个页面的一部分:

authordivabbr向左浮动。这些articlediv 中的每一个都需要与其兄弟姐妹分开 5px 左右。但是,authordiv 超出了 div 的技术“高度”。什么都不做,margin-bottom因为空间被浮动占用了author

这有点难以想象,所以我把它放在了 server上。

有什么方法可以强制父级至少与其中的所有浮动元素一样高?

如果有人知道我在说什么,谢谢。

0 投票
1 回答
2179 浏览

java - 使用java打印时如何获取Paper的边距?

我正在尝试打印一个带有一些绘制图形的JPanel(覆盖paintComponent)。图形是如此之大,以至于它们不适合单个页面,因此我让它跨越多个页面。我的问题在于,如果我让用户通过调用来选择 pageFormat/Paper 类型:

当我在 JPanel 类中编写 print() 方法(实现 Printable)时,我似乎无法控制边距?我graphics.translate(pageFormat.getImageableX(), pageFormat.getImageableY());用来让它在正确的左上角 (0;0) 开始绘制,并考虑到边距(即,从 (80; 100) 左右开始更多)。但随后它会打印在底部和右边距上,我不希望它这样做,因为这否定了用户的意愿。

这是我的 print() 方法的代码作为参考,当您不让用户设置纸张时(使用默认值代替),它可以正常工作:

0 投票
2 回答
1441 浏览

css - 用于定位的 CSS 负边距

可以使用负边距进行定位吗?我当前的站点中有很多内容,并且觉得这不是一种稳定的定位方式。我通常建议也使用它们。

例如,我有一个结帐页面,其中三个 div 相互重叠

(A、B 和 C),它们旨在彼此叠放在一起,以显示为依附。我这样做是使用:

在 div B 上,与 div A 的底部相遇。

top这是一种好习惯还是我应该使用and重新编码left

0 投票
1 回答
1023 浏览

silverlight - Silverlight 和数据绑定属性动画(边距)

我有边界元素,其 Margin 属性绑定到某个类的 StartDate (DateTime) 属性。如果属性更改边距也更改(在转换器的帮助下)。

我想尽可能顺利地进行更改。例如,在 UI 端,数据类中的一小时等于屏幕上的 15 像素,当我更改 StartDate +/- 一小时时,我可以看到元素边距向右/向左跳跃 +/- 15 像素......那我怎么能动画这个?

先感谢您!

顺便说一句 - 这是我在这里的第一个问题:)

0 投票
0 回答
485 浏览

vsto - 如何使用 VSTO 在 PowerPoint 中的列表项间距之前/之后获取/设置段落

我正在开发 PowerPoint VSTO 插件,并且需要获取列表项之间的边距。在 PowerPoint 界面中,您可以通过右键单击单个段落并选择段落,然后在“间距”部分调整“之前”或“之后”值来调整此值(适用于 PowerPoint 2007)。当段落不在列表中时,您可以在此处编辑段落之间的边距。因此,在代码方面,通过 VSTO 中的 Shape 对象,我可以通过检查 Shape.TextFrame2.TextRange.Paragraph[index].ParagraphFormat.SpaceBefore 属性来访问不在列表中的有效值。当我在段落位于列表中并且前面的空格不是 0 时使用此属性时,它始终具有 .2 作为值。使用 Shape.TextFrame.TextRange... 属性也无济于事。