Reputation: 3944
I'm making a little Go board, in just CSS, and have got a problem when I put a counter on a point.
HTML:
<div class="GoBoard">
<div class="aa black"></div>
<div class="ab"></div>
<div class="ba"></div>
<div class="bb white"></div>
</div>
CSS:
.GoBoard{
position:relative;
background-color: #630;
width: 100px;
height: 100px;
}
.GoBoard>div{
position: absolute;
width: 50px;
height: 50px;
}
.GoBoard>div:before, .GoBoard>div:after {
content: "";
position: absolute;
z-index: 0;
background-color: #000;
}
.GoBoard>div:before {
left: 50%;
width: 2%;
margin-left: -1%;
height: 100%;
}
.GoBoard>div:after {
top: 50%;
height: 2%;
margin-top: -1%;
width: 100%;
}
.white{
border-radius: 50%;
background-color:none!important;
z-index: 1!important;
background-image: -moz-radial-gradient(15px 15px 45deg, circle cover, #ddd 0%, #555 100%)!important;
background-image: -webkit-radial-gradient(15px 15px, circle cover, #ddd, #555)!important;
background-image: radial-gradient(15px 15px 45deg, circle cover, #ddd 0%, #555 100%)!important;
}
.black{
border-radius: 50%;
background-image: -moz-radial-gradient(15px 15px 45deg, circle cover, #333 0%, #000 100%);
background-image: -webkit-radial-gradient(15px 15px, circle cover, #333, #000);
background-image: radial-gradient(15px 15px 45deg, circle cover, #333 0%, #000 100%);
}
.aa{bottom:0px;left:0px}
.ab{bottom:50px;left:0px}
.ba{bottom:0px;left:50px}
.bb{bottom:50px;left:50px}
I used the .GoBoard>div as the #cross from this question. And the !important's were to show that this question doesn't work. Adding position: relative; to the .white, with !important takes it out of the board, and without makes no difference. I also tried moving the .white, up the CSS and changing it to .white:before, the former made no difference, and the latter changed the cross line to the color of the circle.
I can think of changing the HTML and CSS to have another class for the cross, but I would prefer if the cross would go below the image. Or having a new div for the cross, which seems like a bit of a waist of a div if you can get this close without it.
tl;dr: How do I get the counter (background-image) above the board cross (background-color)?
Upvotes: 0
Views: 532
Reputation: 8077
I setup this JSFiddle.
Basically, you will only need 2 z-index
's defined in your CSS:
.GoBoard{
z-index: 0;
}
.GoBoard>div:before, .GoBoard>div:after {
z-index: -1;
}
The one you have defined under .white
selector is unnecessary. Also, this is a pretty awesome pure CSS setup!
Upvotes: 1