Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to background a div without the padding area

Tags:

html

css

I have this class on CSS :

.mgmtError{    width:716px;    float:left;    background-color:#FF0000;    padding:10px;    text-align:center; }  

and I'd like to color the background not in the padding area. I tryed with margin, but seems that it have some troubles with IE.

Any others solution?

like image 991
kwichz Avatar asked May 05 '11 10:05

kwichz


People also ask

Does background color apply to padding?

Rather than leave the padding transparent, you can add color to the padding since the background color doesn't fully extend past the text element.

Does padding affect background image?

The padding-box value means that the only the padding box part of the HTML element has the background image rendered. The content-box value means that the only the content box part of the HTML element has the background image rendered.

How do I change my padding background?

you can use background-origin:padding-box; and then add some padding where you want, for example: #logo {background-image: url(your/image. jpg); background-origin:padding-box; padding-left: 15%;} This way you attach the image to the div padding box that contains it so you can position it wherever you want.


1 Answers

You can use

background-clip: content-box; 

Also make sure to use background-color property, not background.

like image 143
Yacine Zalouani Avatar answered Sep 28 '22 03:09

Yacine Zalouani