我正在尝试将背景图片(同一张)应用于两个 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 没有背景。
最佳答案
不要在你的 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; }
关于html - CSS 不申请第二次进入,这里的行有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11338458/