1
所以我试着在CSS前后尝试CSS伪类。我试图使用这些伪创建标题元素。这是为了减少使用div来保存左和右图像。这是为HTML前后使用CSS伪类
<header id="mastHead">
<h1><a href="#">Branding</a></h1>
</header>
代码所以我有3个图像来创建传统头元件,它是20像素宽度为左侧和右侧100像素高度和用于中间,1px的宽度和高度100像素,其将重复水平的。在这里,我的CSS
#mastHead {
background:url(images/headMiddle.jpg) repeat-x top left;
width:1000px;
height:100px;
overflow:hidden;
}
#mastHead:before {
content:"";
display:block;
background:url(images/headLeft.jpg) no-repeat top left;
width:20px;
height:100px;
float:left;
}
#mastHead:after {
content:"";
display:block;
background:url(images/headRight.jpg) no-repeat top left;
width:20px;
height:100px;
float:right;
}
#mastHead h1 a {
display:block;
width:200px;
height:41px;
background:url(images/logo.png) no-repeat;
}
所以,问题是,如果我删除h1元素,它会完全一致,但如果我把这些元素,这将推动:: after伪堂课下来,而且需要根据剩余空间到它的高度。我可以如何让这个h1元素只占用中间空间而不会影响::空间之后?
它们是伪元素,而不是伪类。 – BoltClock