Reputation: 584
I am trying to add shadow to circle by using
box-shadow: 1px 1px 3px 10px black;
, but it comes up with square border . How can i add the shadow to circle.
.circle {
position: relative;
display: block;
margin: 2em 0;
background-color: transparent;
color: #fff;
text-align: center;
width: 40%;
margin: 0 auto;
box-shadow: 1px 1px 3px 10px black;
}
.circle:after {
display: block;
padding-bottom: 100%;
width: 100%;
height: 0;
border-radius: 50%;
background-color: #1E73BE;
content: "";
}
.circle__inner {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
.circle__wrapper {
display: table;
width: 100%;
height: 100%;
}
.circle__content {
display: table-cell;
padding: 1em;
vertical-align: middle;
}
<div class="circle">
<div class="circle__inner">
<div class="circle__wrapper">
<div class="circle__content">This is responsive circle</div>
</div>
</div>
</div>
Upvotes: 1
Views: 234
Reputation: 11
I suggest you to change approach and use position: absolute;
for .circle__content:after
pseudo-element. The final code is the following:
.circle__content:after {
content: "";
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
border-radius: 50%;
background-color: transparent;
z-index: -1;
box-shadow: 0 0 5px #000;
}
Upvotes: 1
Reputation: 14149
Add border-radius
this class .circle
.circle {
position: relative;
display: block;
margin: 2em 0;
background-color: transparent;
color: #fff;
text-align: center;
width: 40%;
margin: 0 auto;
box-shadow: 1px 1px 3px 10px black;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
.circle:after {
display: block;
padding-bottom: 100%;
width: 100%;
height: 0;
border-radius: 50%;
background-color: #1E73BE;
content: "";
}
.circle__inner {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
.circle__wrapper {
display: table;
width: 100%;
height: 100%;
}
.circle__content {
display: table-cell;
padding: 1em;
vertical-align: middle;
}
<div class="circle">
<div class="circle__inner">
<div class="circle__wrapper">
<div class="circle__content">This is responsive circle</div>
</div>
</div>
</div>
Upvotes: 1
Reputation: 8695
Add border-radius: 50%;
to the .circle
CSS
.circle {
position: relative;
display: block;
margin: 2em 0;
background-color: transparent;
color: #fff;
text-align: center;
width: 40%;
margin: 0 auto;
box-shadow: 1px 1px 3px 10px black;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
Upvotes: 1