html - CSS 不申请第二次进入,这里的行有什么问题?

标签 html css

我正在尝试将背景图片(同一张)应用于两个 div 标签:

.abc { background: url('images/autogen.png') no-repeat 0px -133px; width: 256px; height: 256px; };

.def { background: url('images/autogen.png') no-repeat 0px -0px; width: 128px; height: 128px; };

HTML:

<html><head><meta charset="utf8"><link href='main.css' rel='stylesheet' type='text/css'' media='all' /></head><body>
<div class="def">def</div>
<div class="abc">abc</div></body></html>

但是只有一个被显示,如果我把 .def 定义放在 .abc 之前,.def 被显示而 .abc 没有背景。

enter image description here

最佳答案

不要在你的 css 之后使用 ;

替换

.abc { 
background: url('images/autogen.png') no-repeat 0px -133px; 
width: 256px;
height: 256px;
};

.def { background: url('images/autogen.png') no-repeat 0px -0px; 
width: 128px;
height: 128px; };

这个

     .abc { background: url('images/autogen.png') no-repeat 0px -133px; 
width: 256px; 
height: 256px; }

        .def { background: url('images/autogen.png') no-repeat 0px -0px; 
width: 128px; 
height: 128px; }

更多信息 http://htmlhelp.com/reference/css/structure.html

关于html - CSS 不申请第二次进入,这里的行有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11338458/

相关文章:

html - 如何在 PHONE GAP 中为 Android 设备修复此 STICKY 页脚?

javascript - 是否可以模拟 iframe?

javascript - 移动 View 结束后 float 不返回位置

css - javafx 2,CSS 和焦点消失

html - 选择菜单填充但不移动下拉箭头

javascript - AngularJS ngTable延迟显示ajax数据

css display : what? - 一个接一个地排列盒子

html - 是否可以在电子邮件中使用 'Open Sans'

javascript - 如何在div中居中img

javascript - 粘性页脚直到文档高度大于视口(viewport)