Div宽度对我不起作用

时间:2013-05-29 23:48:51

标签: css html styles

<div id="content" style ="background-color:#ffffff;" style="width:600px;">

用它制作div并使背景变白。但是我沿着页面的整个宽度拉伸。我怎么才能做到这一点只能拉伸我放入的尺寸?

3 个答案:

答案 0 :(得分:1)

您有两次style属性。那是无效的。只把它放在那里一次。

<div id="content" style="background-color:#ffffff; width:600px;">

更好的是,使用CSS

<div id="content">

#content {
    background-color: #fff;
    width: 600px;
}

答案 1 :(得分:0)

您有两个导致错误的style属性。用这个:

<div id="content" style="background-color:#ffffff; width:600px;">

答案 2 :(得分:0)

您不能多次使用相同的属性..

CSS规则可以用;

分隔
<div id="content" style ="background-color:#ffffff;width:600px;">
相关问题