Replicate image in CSS and HTML only - html

For a code quiz I am trying to replicate the attached image using CSS and HTML only. The gradients and borders seem to be working out fine, but I am having trouble getting the ribbon edges to look curved.
Here is my markup:
<div class="container">
<div class="ribbon-wrapper-green"><div class="ribbon-green">AWESOME!</div></div>
<div class="ribbon-bottom-left"></div>
<div class="bottom-left-gradient"></div>
And here is my CSS:
.container {
width:300px;
height:300px;
margin-left:auto;
margin-right:auto;
margin-top:10px;
position:relative;
border:#CCC 1px solid;
background-color:#EBEBEB;
box-shadow:1px 1px 1px #CCC;
}
.ribbon-wrapper-green {
width: 290px;
height: 290px;
overflow: hidden;
position: absolute;
top: -3px;
right: -3px;
}
.ribbon-green {
font: 25px Arial;
text-align: center;
text-shadow:0px 0px 6px #000;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
position: relative;
padding: 20px 0;
left: 7px;
top: 66px;
width: 363px;
background-color: #BFDC7A;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45));
background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -moz-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -ms-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -o-linear-gradient(top, #BFDC7A, #8EBF45);
color: #FFF;
-webkit-box-shadow: 0px 8px 20px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 8px 20px rgba(0,0,0,0.3);
box-shadow: 0px 8px 20px rgba(0,0,0,0.3);
}
.ribbon-green:before, .ribbon-green:after {
content: "";
border-top: 4px solid #6e8900;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
position:absolute;
bottom: -4px;
}
.ribbon-green:before {
left: 0;
}
.ribbon-green:after {
right: 0;
}
.ribbon-bottom-left {
width: 0px;
height: 0px;
border-style: solid;
border-width: 250px 0 0 250px;
border-color: transparent transparent transparent #D32023;
position:absolute;
bottom:-5px;
left:-5px;
border-top-left-radius:10px;
border-bottom-right-radius:10px;
-moz-border-radius-topleft:10px;
-moz-border-radius-bottomright:10px;
z-index:1;
}
.bottom-left-gradient {
position:absolute;
bottom:-8px;
left:-8px;
z-index:100;
height:245px;
width:245px;
opacity:0.4;
filter:alpha(opacity=40);
background: -moz-linear-gradient(45deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0.92) 4%, rgba(255,255,255,0) 51%); /* FF3.6+ */
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,rgba(255,255,255,1)), color-stop(4%,rgba(255,255,255,0.92)), color-stop(51%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* Opera 11.10+ */
background: -ms-linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* IE10+ */
background: linear-gradient(45deg, rgba(255,255,255,1) 0%,rgba(255,255,255,0.92) 4%,rgba(255,255,255,0) 51%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
border-style:solid;
border-width:0 0 5px 5px;
border-radius:10px;
-moz-border-radius:10px;
border-color:#E41316;
}
The image is coming out like this example here: http://arunsood.me/code-quizzes/placebo-effect/.
The original I need to copy is below. How can I achieve the edge bending effect via CSS alone?

Related

CSS float right and vertically center an element

I am trying to push the sign out button to the right but have it aligned vertically in the centre.
Here is an example:
#sessionManageWrapper {
max-width: 45%;
}
#sessionManageWrapper .sessionBox:not(:last-child) {
margin-bottom: 5px;
}
.sessionBox {
background-color: #444343;
padding: 4px;
border-radius: 3px;
border: 2px solid grey;
vertical-align: middle;
}
.sessionBox img {
vertical-align: middle;
height: 32px;
width: 32px;
}
.logoutSessWrapper {
float: right;
line-height: 15px;
}
.sessionBox p {
margin: 0;
vertical-align: middle;
display: inline-block;
}
.sessionBox p:not(:last-child) {
margin-right: 10px;
}
.sessionSeparator {
background-color: grey;
width: 1px;
height: 24px;
display: inline-block;
vertical-align: middle;
}
.activeCircle {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
border: 1px solid #ccc;
width: 8px;
height: 8px;
display: inline-block;
vertical-align: middle;
}
.sessionActiveGreen {
background-color: green;
}
.redButton {
-moz-box-shadow: inset 0px 1px 0px 0px #cf866c;
-webkit-box-shadow: inset 0px 1px 0px 0px #cf866c;
box-shadow: inset 0px 1px 0px 0px #cf866c;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d0451b), color-stop(1, #bc3315));
background: -moz-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -webkit-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -o-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -ms-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: linear-gradient(to bottom, #d0451b 5%, #bc3315 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0451b', endColorstr='#bc3315', GradientType=0);
background-color: #d0451b;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 1px solid #942911;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-size: 13px;
padding: 6px 19px;
text-decoration: none;
text-shadow: 0px 1px 0px #854629;
}
.redButton:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bc3315), color-stop(1, #d0451b));
background: -moz-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -webkit-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -o-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -ms-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#bc3315', endColorstr='#d0451b', GradientType=0);
background-color: #bc3315;
}
.redButton:active {
position: relative;
top: 1px;
}
<div id="sessionManageWrapper">
<div class="sessionBox activeSession">
<div class="activeCircle sessionActiveGreen" title="Online, active"></div>
<img src="http://i.imgur.com/k0h3WPJ.png">
<div class="sessionSeparator"> </div>
<p>#currentSessLocation</p>
<p>#currentSessDevice</p>
<p>#currentSessIP</p>
<div class="logoutSessWrapper">Sign Out</div>
</div>
</div>
I know vertically align does not work with float but I can't seem to find a way to get that sign out button centre like the rest of the elements in the session box div.
Just use absolute positioning. It's a simple method to vertically center and right-align the button.
.sessionBox {
background-color: #444343;
padding: 4px;
border-radius: 3px;
border: 2px solid grey;
vertical-align: middle;
position: relative; /* NEW; set nearest positioned ancestor for abspos child */
}
.logoutSessWrapper {
/* float: right; */
line-height: 15px;
position: absolute; /* NEW */
right: 5px; /* NEW */
top: 50%; /* NEW */
transform: translateY(-50%); /* NEW */
}
#sessionManageWrapper {
max-width: 45%;
}
#sessionManageWrapper .sessionBox:not(:last-child) {
margin-bottom: 5px;
}
.sessionBox {
background-color: #444343;
padding: 4px;
border-radius: 3px;
border: 2px solid grey;
vertical-align: middle;
position: relative; /* NEW; set nearest positioned ancestor for abspos child */
}
.sessionBox img {
vertical-align: middle;
height: 32px;
width: 32px;
}
.logoutSessWrapper {
/* float: right; */
line-height: 15px;
position: absolute; /* NEW */
right: 5px; /* NEW */
top: 50%; /* NEW */
transform: translateY(-50%); /* NEW */
}
.sessionBox p {
margin: 0;
vertical-align: middle;
display: inline-block;
}
.sessionBox p:not(:last-child) {
margin-right: 10px;
}
.sessionSeparator {
background-color: grey;
width: 1px;
height: 24px;
display: inline-block;
vertical-align: middle;
}
.activeCircle {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
border: 1px solid #ccc;
width: 8px;
height: 8px;
display: inline-block;
vertical-align: middle;
}
.sessionActiveGreen {
background-color: green;
}
.redButton {
-moz-box-shadow: inset 0px 1px 0px 0px #cf866c;
-webkit-box-shadow: inset 0px 1px 0px 0px #cf866c;
box-shadow: inset 0px 1px 0px 0px #cf866c;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d0451b), color-stop(1, #bc3315));
background: -moz-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -webkit-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -o-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: -ms-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background: linear-gradient(to bottom, #d0451b 5%, #bc3315 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#d0451b', endColorstr='#bc3315', GradientType=0);
background-color: #d0451b;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 1px solid #942911;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-size: 13px;
padding: 6px 19px;
text-decoration: none;
text-shadow: 0px 1px 0px #854629;
}
.redButton:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bc3315), color-stop(1, #d0451b));
background: -moz-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -webkit-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -o-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: -ms-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background: linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#bc3315', endColorstr='#d0451b', GradientType=0);
background-color: #bc3315;
}
.redButton:active {
position: relative;
top: 1px;
}
<div id="sessionManageWrapper">
<div class="sessionBox activeSession">
<div class="activeCircle sessionActiveGreen" title="Online, active"></div>
<img src="http://i.imgur.com/k0h3WPJ.png">
<div class="sessionSeparator"> </div>
<p>#currentSessLocation</p>
<p>#currentSessDevice</p>
<p>#currentSessIP</p>
<div class="logoutSessWrapper">Sign Out</div>
</div>
</div>
jsFiddle
For a complete explanation of how this centering method works see:
Element will not stay centered, especially when re-sizing screen
As far as i understood what you are trying to achieve, i edited your code, and added few divs and few css classes, and it works perfectly, here it is:
HTML
<div id="sessionManageWrapper">
<div class="sessionBox activeSession">
<div class="activeCircle sessionActiveGreen" title="Online, active"></div>
<img src="http://i.imgur.com/k0h3WPJ.png">
<div class="sessionSeparator"> </div>
<p>#currentSessLocation</p>
<p>#currentSessDevice</p>
<p>#currentSessIP</p>
<!-- additional Markup -->
<div class="wrap">
<div class="dt">
<div class="dc">
<div class="logoutSessWrapper">Sign Out</div>
</div>
</div>
</div>
</div> <!-- wrap ends -->
</div>
ADDITIONAL CSS
#sessionManageWrapper {
max-width: 45%;
position: relative;
}
.dt {
display: table;
width: 100%;
height: 100%;
}
.wrap {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
}
.dc {
display: table-cell;
vertical-align: middle;
}
Here is a fiddle of it

How to add two stars in CSS through :after?

I need to add two stars icons without using any image or font awesome. I need to add them in CSS through :after, is this possible?
I want it to look like this:
Currently it looks like this:
a {
width: 247px;
height: 59px;
float: none;
margin: 100px auto;
font-family: Arial, Helvetica, sans-serif;
font-size: 25px;
font-weight: bold;
color: #555555;
text-align: center;
text-transform: uppercase;
text-decoration: none;
line-height: 59px; /* http://colorzilla.com/gradient-editor/#e3e3e3+0,d2d2d2+50,c6c6c6+51,adadad+100 */
background: #e3e3e3; /* Old browsers */
background: -moz-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#e3e3e3', endColorstr='#adadad', GradientType=0); /* IE6-9 */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0 1px 3px 1px #777777;
box-shadow: 0 1px 3px 1px #777777;
text-shadow: 0 1px 0 #dedede;
position: relative;
display: block;
}
a:before {
width: 261px;
height: 73px;
position: absolute;
top: -9px;
left: -10px;
background: #cbcbcb;
content: "";
border: #fff 2px solid;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-box-shadow: 0 0 0 2px #666666;
box-shadow: 0 0 0 2px #666666;
z-index: -1;
}
a:after {
width: 247px;
height: 59px;
position: absolute;
top: -9px;
left: -9px;
background: none;
content: "";
z-index: 1;
}
Checkout
One possible solution is to use white-space: pre;, so that you can attach two stars and display each one at each side of the button with just :after as you asked.
a:after {
...
content: "✭ ✭";
white-space: pre;
}
a {
position: relative;
display: block;
width: 247px;
height: 59px;
margin: 100px auto;
font-family: Arial, Helvetica, sans-serif;
font-size: 25px;
font-weight: bold;
color: #555555;
text-align: center;
text-transform: uppercase;
text-decoration: none;
line-height: 59px;
background: -webkit-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
background: linear-gradient(to bottom, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
border-radius: 8px;
box-shadow: 0 1px 3px 1px #666;
text-shadow: 0 1px 0 #dedede;
}
a:before {
position: absolute;
z-index: -1;
top: -9px;
left: -9px;
width: 261px;
height: 73px;
content: "";
border: #fff 2px solid;
border-radius: 15px;
background: #cbcbcb;
box-shadow: 0 0 0 2px #666;
}
a:after {
position: absolute;
z-index: 1;
top: 0;
left: 0;
width: 247px;
height: 59px;
content: "✭ ✭"; /* \2605 */
white-space: pre;
}
Checkout
One other way is to put all relevant styles into one place, so that you'll have both :before and :after free to use for the stars, and control the position of each one individually.
a {
...
box-shadow: 0 1px 3px 1px #666, 0 0 0 7px #ccc, 0 0 0 9px #fff, 0 0 0 11px #666;
}
a:before, a:after {
content: "✭";
}
a:before {
margin-right: 12px
}
a:after {
margin-left: 12px;
}
a {
position: relative;
display: block;
width: 247px;
height: 59px;
margin: 100px auto;
font-family: Arial, Helvetica, sans-serif;
font-size: 25px;
font-weight: bold;
color: #555555;
text-align: center;
text-transform: uppercase;
text-decoration: none;
line-height: 59px;
background: -webkit-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
background: linear-gradient(to bottom, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
border-radius: 6px;
box-shadow: 0 1px 3px 1px #666, 0 0 0 7px #ccc, 0 0 0 9px #fff, 0 0 0 11px #666;
text-shadow: 0 1px 0 #dedede;
}
a:before,
a:after {
content: "✭"; /* \2605 */
}
a:before {
margin-right: 12px
}
a:after {
margin-left: 12px;
}
Checkout
You can use the :before and :after to insert the FontAwesome stars before and after the link text, like this:
a:before,
a:after {
display:inline-block;
font:normal normal normal 14px/1 FontAwesome;
font-size:inherit;
text-rendering:auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #888;
}
a:before {
content:"\f005"; /* FontAwesome star content */
margin-right: 10px;
}
a:after {
content:"\f005"; /* FontAwesome star content */
margin-left: 10px;
}
And you don't need to use :before and :after to achieve your extra bordering effects. You can simply use comma separated box-shadow values with to achieve the same effect, like this:
box-shadow: 0 1px 3px 1px #777777, 0 0 0 10px #cbcbcb, 0 0 0 12px #fff, 0 0 0 14px #000;
The working example:
body {
margin: 0;
padding: 0;
}
a {
width: 247px; height:59px; float:none; margin:100px auto; font-family:Arial, Helvetica, sans-serif; font-size:25px; font-weight:bold; color:#555555; text-align:center; text-transform:uppercase; text-decoration:none; line-height:59px; /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#e3e3e3+0,d2d2d2+50,c6c6c6+51,adadad+100 *
background: #e3e3e3;
/* Old browsers */
background: -moz-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#e3e3e3', endColorstr='#adadad', GradientType=0);
/* IE6-9 */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0 1px 3px 1px #777777;
box-shadow: 0 1px 3px 1px #777777, 0 0 0 10px #cbcbcb, 0 0 0 12px #fff, 0 0 0 14px #000;
text-shadow: 0 1px 0 #dedede;
position: relative;
display: block;
}
a:before,
a:after {
display:inline-block;
font:normal normal normal 14px/1 FontAwesome;
font-size:inherit;
text-rendering:auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #888;
}
a:before {
content:"\f005";
margin-right: 10px;
}
a:after {
content:"\f005";
margin-left: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
Checkout
I edit your CSS code Please check carefully.
body {
margin: 0;
padding: 0;
text-align: center;
}
a {
width: 247px; height:59px; float:none; margin:100px auto; font-family:Arial, Helvetica, sans-serif; font-size:25px; font-weight:bold; color:#555555; text-align:center; text-transform:uppercase; text-decoration:none; line-height:59px; /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#e3e3e3+0,d2d2d2+50,c6c6c6+51,adadad+100 *
background: #e3e3e3;
/* Old browsers */
background: -moz-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #e3e3e3 0%, #d2d2d2 50%, #c6c6c6 51%, #adadad 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#e3e3e3', endColorstr='#adadad', GradientType=0);
/* IE6-9 */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0 1px 3px 1px #777777;
box-shadow: 0 1px 3px 1px #777777;
text-shadow: 0 1px 0 #dedede;
position: relative;
display: inline-block;
}
a:before {
width: 261px;
height: 73px;
position: absolute;
top: -9px;
left: -10px;
background-color: transparent;
background-attachment: scroll;
background-image: url(https://www.podomatic.com/assets/homebase/icon-star-64091d94372b5effa95e1f6f8d07846e.png);
background-position: left 30px center;
background-repeat: no-repeat;
background-size: 20px 20px;
content: "";
border: #fff 2px solid;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-box-shadow: 0 0 0 2px #666666;
box-shadow: 0 0 0 2px #666666;
z-index: 0;
}
a:after {
background-color: transparent;
background-attachment: scroll;
background-image: url(https://www.podomatic.com/assets/homebase/icon-star-64091d94372b5effa95e1f6f8d07846e.png);
background-position: right 30px center;
background-repeat: no-repeat;
background-size: 20px 20px;
width: 261px;
height: 73px;
position: absolute;
top: -9px;
left: -9px;
/*background: none;*/
content: "";
z-index: 1;
}
Checkout
For anyone looking for Pure CSS stars, because the original poster stated they didn't want to use fontawesome or images, here's the code :
<!doctype html>
<html>
<head>
<title>Untitled</title>
<style>
.starCont{
display:inline-block;
position: relative;
}
.tri-1 {
position: relative;
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 8px solid #f8f800;
}
.tri-2 {
width: 0;
height: 0;
border-top: 16px solid transparent;
border-bottom: 7px solid transparent;
border-left: 5px solid #f8f800;
transform: rotate(16deg);
position: absolute;
top: -17px;
left: -3px;
}
.tri-3 {
width: 0;
height: 0;
border-top: 16px solid transparent;
border-bottom: 7px solid transparent;
border-right: 5px solid #f8f800;
transform: rotate(-16deg);
position: absolute;
top: -17px;
left: -2px;
}
</style>
</head>
<body>
<div class="starCont">
<div class="tri-1"><div class="tri-2"></div><div class="tri-3"></div></div>
</div> Star Rating
</body>
</html>
Use the -webkit and -mz prefixes for the transform properties to have the star rendered in older browsers. Otherwise, it's a world first, because after searching for a while, I couldn't find any stars using Pure CSS. I should credit the CSS-Tricks website, which posted the triangles, which gave me the idea for overlapping 3 triangles, then rotating 2 of them, to create a star.

How do I change the color and style of radio buttons

I have a code to modify but it is not working
HTML
<input type="radio" id="radio-1-1" name="radio-1-set" class="regular-radio" checked />
Css
.regular-radio:checked:after {
content: ' ';
width: 12px;
height: 12px;
border-radius: 50px;
position: absolute;
top: 3px;
background: #99a1a7;
box-shadow: inset 0px 0px 10px rgba(0,0,0,0.3);
text-shadow: 0px;
left: 3px;
font-size: 32px;
}
.regular-radio:checked {
background-color: #e9ecee;
color: #99a1a7;
border: 1px solid #adb8c0;
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05), inset 15px 10px -12px rgba(255,255,255,0.1), inset 0px 0px 10px rgba(0,0,0,0.1);
}
I need radio box like :-
Let me know how can I do this ?
Thanks.
It is possible in css, but not for all the browsers.
The effect on all browsers:
http://www.456bereastreet.com/lab/form_controls/checkboxes/
A possibility is a custom checkbox with javascript, example:
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/
You can do it without javascript.
By default HTML works so that your label will trigger the input. This means that you can hide your input, and put a psudo element on you label. In that way you can style whatever radio button / checkbox you would like.
Now I didn't test the below code, put it should be close to this.
By the way. The reason for not displaying none on the input, is because it makes IOS crash, for some reason.
<label for="test">
<input type="radio" id="test" />
</label>
CSS
input {
position: absolute;
left: - 999em;
}
label {
position relative;
padding-left: 30px;
}
label:before {
content: "";
display: block;
height: 10px;
width: 10px;
background: url(yourBackgroundImage.png) no-repeat 0 0;
position: absolute;
left: 0;
top: 2px;
}
I think it is a rounded check box. Not a radio button. Here is how it did.
Here is the jsfiddle: http://jsfiddle.net/X55am/
Here is some extra: http://codepen.io/bbodine1/pen/novBm
html
<div class="roundedTwo">
<input type="checkbox" value="None" id="roundedTwo" name="check" />
<label for="roundedTwo"></label>
</div>
css
body {
background: #555;
}
input[type=checkbox] {
visibility: hidden;
}
/* ROUNDED TWO */
.roundedTwo {
width: 28px;
height: 28px;
background: #fcfff4;
background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfff4', endColorstr='#b3bead',GradientType=0 );
margin: 20px auto;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
-webkit-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5);
-moz-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5);
box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5);
position: relative;
}
.roundedTwo label {
cursor: pointer;
position: absolute;
width: 20px;
height: 20px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
left: 4px;
top: 4px;
-webkit-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1);
-moz-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1);
box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1);
background: -webkit-linear-gradient(top, #222 0%, #45484d 100%);
background: -moz-linear-gradient(top, #222 0%, #45484d 100%);
background: -o-linear-gradient(top, #222 0%, #45484d 100%);
background: -ms-linear-gradient(top, #222 0%, #45484d 100%);
background: linear-gradient(top, #222 0%, #45484d 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#222', endColorstr='#45484d',GradientType=0 );
}
.roundedTwo label:after {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
content: '';
position: absolute;
width: 9px;
height: 5px;
background: transparent;
top: 5px;
left: 4px;
border: 3px solid #fcfff4;
border-top: none;
border-right: none;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.roundedTwo label:hover::after {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
opacity: 0.3;
}
.roundedTwo input[type=checkbox]:checked + label:after {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
}

force div to surround another div

At the moment I have a parent div containing 2 div's, both div's have their own border. What I try to do is to have 1 div in the left top corner and the other div surround it on the right and bottom with margin between them. Just like the image below:
Is this even possible, using css3 and html5?
Edit: Here is the layout of the div's.
<div id="main">
<div id="leftdiv">
Here is some text and an image displayed
</div>
<div id="rightdiv">
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
<div class="profile"><h4>Some text</h4><img src="...."></div>
..............
</div>
</div>
You could try to fake this effect with pseudo-elements for the top-left container.
.first {
position: relative;
float: left;
height: 30px;
width: 30px;
border: 1px solid black;
margin: 0 5px 5px 0;
}
.first:after {
content: '';
position: absolute;
top: -1px;
right: -5px;
height: 35px;
width: 3px;
background-color: #fff;
border-right: 1px solid black;
}
.first:before {
content: '';
position: absolute;
bottom: -5px;
left: -1px;
height: 3px;
width: 35px;
background-color: #fff;
border-bottom: 1px solid black;
}
.second {
height: 80px;
width: 100px;
border: 1px solid black;
}
See this fiddle:
http://jsfiddle.net/fqsDp/2/
I have the following in jsfiddle.com:
#main {
float: left;
width: 400px;
}
#leftdiv {
float: left;
margin: 0 0.5em 0.5em 0;
background: green;
color: black;
width: 150px;
height: 150px;
background: rgb(255,255,255);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNkYmRiZGIiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(219,219,219,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(219,219,219,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dbdbdb',GradientType=0 );
border: 1px solid #E2E2E2;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#rightdiv {
background: rgb(255,255,255);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNkYmRiZGIiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(219,219,219,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(219,219,219,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(219,219,219,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dbdbdb',GradientType=0 );
border: 1px solid #E2E2E2;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
http://jsfiddle.net/5unJw/

CSS3 create this button using only single DIV

I am trying to create a button similar to this in CSS3. (all HTML5 browsers should be supported):
Button image
HTML:
<div class="buttonClass">Nitin Mukesh</div>
CSS:
body {
background: gray;
margin-top: 50px;
margin-left: 50px;
}
.buttonClass {
width: 300px;
height: 40px;
padding: 10px 60px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
background: -moz-linear-gradient(top, #FFFFFF 0%, #91BDD6 100%); /* firefox */
border: solid #91BDD6 5px;
outline: solid #fff 5px;
-moz-box-shadow: 3px 1px 24px #000000;
-webkit-box-shadow: 3px 1px 24px #000000;
box-shadow: 3px 1px 24px #000000;
}
JSFiddle
I could possible think of a solution that using 2 div will solve the problem with outer div hold the white outline and box-shadow and inner div with outline and gradient color.
Is it possible to achieve this using single div.
Many thanks for any inputs
This is what I came up with: http://jsfiddle.net/psycketom/heGu9/2/
.button
{
display: block;
background-image: linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -o-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -moz-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -ms-linear-gradient(bottom, rgb(145,189,214) 0%, rgb(255,255,255) 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(145,189,214)),
color-stop(1, rgb(255,255,255))
);
/* Added second shadow for that "black" effect */
box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-o-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-ms-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-moz-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
-webkit-box-shadow: 0px 0px 0px 5px white, 0px 0px 10px 5px black;
border-radius: 15px;
-o-border-radius: 15px;
-ms-border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border: solid 5px rgb(145,189,214);
padding: 60px;
margin: 7px; /* to complement the outside shadow */
}
box-shadow can have multiple shadow, so:
http://jsfiddle.net/cyzw8/4/
.buttonClass {
width: 200px;
height: 40px;
/* padding: 10px 60px;*/
text-align:center;
line-height:40px;
border-radius: 7px;
background-image:-webkit-linear-gradient(top,#FFF 0%,#91BDD6 100%);
background-image: -moz-linear-gradient(top, #FFFFFF 0%, #91BDD6 100%);
background-image:-ms-linear-gradient(top,#FFF,#91BDD6);
background-image:-o-linear-gradient(top,#FFF,#91BDD6);
background-image:linear-gradient(top,#FFF,#91BDD6);
border: solid #91BDD6 5px;
box-shadow: 0px 0px 0px 5px #fff, 5px 3px 12px #000000;
}
This is what I see in my Chrome:
Here is a second way http://jsfiddle.net/Merec/Va4qG/
<div class="buttonClass"><span>Nitin Mukesh</span></div>
.buttonClass {
display: inline-block;
background: #fff;
border: 2px solid #fff;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: rgb(255,255,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(145,189,214,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(145,189,214,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(145,189,214,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#91bdd6',GradientType=0 ); /* IE6-9 */
}
.buttonClass span {
padding: 5px 10px;
display: block;
border: 2px solid #91bdd6;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}