css布局与背景颜色 [英] css layouts with background colour

查看:182
本文介绍了css布局与背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用背景颜色设置弹性布局,然后将身体居中。但它不适用于浏览器。这是HTML和CSS,它看起来不错,但我一定做错了。


CSS

I am trying to set up an elastic layout with a background colour, then the body centred. But it is not working in the browsers. Here is the HTML and CSS, it looks OK to me but I must be doing something wrong.

CSS

展开 | 选择 | Wrap | 行号

推荐答案

你身体外有一个div元素,这是无效的,不能这样使用。你的class属性在它自己的标签中.... class是一个属性而不是一个元素。此外,您的div和ID之间也有一段时间,这也是无效的。此外,你的CSS后面有一个head,body和html标签。在外部样式表中,您不包含标签。


尝试将代码更改为此,看看它是否符合您的要求。


HTML


[HTML]< html>


< head>

< meta http-equiv = QUOT;内容语言与QUOT; content =" en-gb">

< meta http-equiv =" Content-Type"含量=" text / html的; charset = windows-1252">

< title>新页面1< / title>

< link rel =" stylesheet"类型= QUOT;文本/ CSS" href =" new_page_1.css">

< / head>


< body>

< div id =" container">


< div id =" header">

< img src =" images / networkartslogo。 GIF" ALT ="标志" />

< / div>


< / div>

< / body>


< / html>

[/ HTML]


CSS(记住没有标签只是纯CSS)

You have a div outside of your body element, that''s not valid, and can''t be used that way. You have your class attribute in its own tag....class is an attribute not an element. Also you have a period inbetween your ''div'', and your ''id'', that is also not valid. Furthermore you have a head, body, and html tags after your CSS. In external stylesheets you do not include tags.

Try changing your code to this and see if it''s what you want.

HTML

[HTML] <html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<link rel="stylesheet" type="text/css" href="new_page_1.css">
</head>

<body>
<div id="container">

<div id="header">
<img src="images/networkartslogo.gif" alt="Logo" />
</div>

</div>
</body>

</html>
[/HTML]


CSS (remember no tags just pure CSS)

展开 | 选择 < span class =codeDivider> | Wrap | 行号




感谢您告诉我出错的地方,它现在工作正常。
Hi
thanks for letting me know where I was going wrong, it works fine now.




再说一遍,一切正常,只是当使用全宽浏览器时标题图像不居中,所以我不想要。


CSS显示:
Hi
Back again, everything works OK except that the header image is not centred when the full width browser is used, so that is not want I want.

CSS shows this:
展开 | 选择 | Wrap | 行号


这篇关于css布局与背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆