Forum Moderators: not2easy
<div class="left"></div>
<div class="mid">Button</div>
<div class="right"></div>
<div class="my-button">Button</div>
.my-button {
background: transparent url('images/bt-cn.png') no-repeat;
background-size: auto 40px;
line-height: 48px;
}
.my-button:before {
display: block;
content: "";
width: 13px;
height: 48px;
background: transparent url('images/bt-lf.png') no-repeat;
float: left;
margin-right: 10px;
}
.my-button:after {
display: block;
content: "";
width: 13px;
height: 48px;
background: transparent url('images/bt-rt.png') no-repeat;
float: right;
}
have a repeated background image on the mid div.
<snip>
.my-button {
background: transparent url('images/bt-cn.png') no-repeat;
but it's not supported in IE at all is it?
But :before and :after pseudo-elements go inside the real element's margins and padding-- they're really shorthand for "content begins with" and "content ends with"-- so wouldn't you be right back where you started?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<title>polyglot HTML5 test</title>
<style>
html, body {
height: 100%;
background: rgb(255,255,128);
}
#target {
width: 50%;
height: 100px;
line-height: 100px;
text-align: center;
background-color:rgba(0,255,0,0.5);
margin: 0 100px;
position: relative;
}
#target:before, #target:after {
width: 100px;
height: 100px;
position: absolute;
top:0;
}
#target:before {
content:"red";
background-color:rgba(255,0,0,0.5);
left:-100px;
}
#target:after {
content:"blue";
background-color:rgba(0,0,255,0.5);
right:-100px;
}
</style>
</head>
<body>
<div id="target">GREEN</div>
</body>
</html>