Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird issue with padding and whitespace: nowrap in Chrome and IE

Tags:

html

css

I ran into really weird issue. ( http://jsfiddle.net/Fq68D/ )

HTML

<div>
    <p>Hello World!</p>
</div>

CSS

div {
    display:inline-block;
}
p {
    background-color:#ccc;
    padding:10%;
    white-space:nowrap;
}

In Firefox it works like expected, text fits in p, and has padding,

While in Chrome and IE text gets out of box.

enter image description here

What causes this? Any workarounds?

like image 622
Tonik Avatar asked May 09 '13 21:05

Tonik


1 Answers

Add display: inline-block; to p element:

http://jsfiddle.net/Fq68D/1/

like image 137
WooCaSh Avatar answered Oct 03 '22 23:10

WooCaSh