开发者

How come my <textarea> is not centered when it parents are centered with 'margin: 0 auto'?

For some reason my textarea DIV is not inheriting

margin: 0 auto

from its parent:

*
{
    padding: 0;
    margin: 0 auto;
}

Here is a link to my CSS & HTML for this example

How can I make it so that the textarea开发者_Python百科 DIV actually gets centered?


Add display:block; to textarea style. After that textarea will be treated as block element and will be displayed centered.

textarea
{
    display:block;
        resize: none;
    overflow: hidden;
    width: 460px;
    padding: 3px;   
}


By default, margins are not inherited. You need to specifiy margin: 0 auto; explicitly for the textarea in question. Otherwise, the containing element will be centered, but the textarea will be laid out inside the container according to the regular flow (ie., margin: 0;).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜