Matthew905
Matthew905

Reputation: 1601

Css, Can I use negative padding so that together with a border they appear outside the container?

What I’m trying to achieve is a top border that matches up (i.e. overlaps) exactly with the bottom border of an element above.

Any ideas on how to achieve this?

Upvotes: 2

Views: 12381

Answers (5)

Omer Tuchfeld
Omer Tuchfeld

Reputation: 3022

Your problem can easily be solved without messing with the margin/padding, just remove the bottom border, which will make it look as if it was overlapping.

border-bottom:none;

http://jsfiddle.net/E9XHA/

If your borders are side by side just remove the right/left border... etc

Upvotes: 0

RobertO
RobertO

Reputation: 2663

Can I use negative padding so that together with a border they appear outside the container

No, but you can use negative margin. Anyway, I'd set only left and right border of inner element.

Upvotes: 0

Paul D. Waite
Paul D. Waite

Reputation: 98816

Yup, but not with padding. Use a negative top margin instead.

See http://jsfiddle.net/TD9x7/

Upvotes: 1

corroded
corroded

Reputation: 21564

either you use negative margins or absolute positioning. negative values are not allowed

Upvotes: 0

Ross
Ross

Reputation: 17977

Negative padding is not allowed, nor in the CSS spec as far as I'm aware. Padding is for adjustments within the box model, margin is for adjustments outside.

You may be able to achieve the desired affect with a negative margin

margin-top:-20px;

for instance.

But it would help to see your code to offer more assistance.

Upvotes: 6

Related Questions