<div class="inputs">
<input id="border-box" checked name="box_selectors" type="radio"/>
<label for="border-box">border-box</label>
<input id="padding-box" name="box_selectors" type="radio"/>
<label for="padding-box">padding-box</label>
<input id="content-box" name="box_selectors" type="radio"/>
<label for="content-box">content-box</label>
</div>
<div class="box">
<div class="little_box"></div>
</div>
.box {
position: relative;
background: #545454 url(//lorempixel.com/300/300/cats/1);
height: 200px;
width: 200px;
margin: 0 auto;
border: 18px solid rgba(0, 0, 0, 0.3);
background-clip: border-box;
background-origin: border-box;
background-size: cover;
background-repeat: no-repeat;
padding: 30px;
}
.little_box {
text-align: center;
color: white;
font-size: 1.5em;
width: 100%;
height: 100%;
padding: 4px;
box-sizing: border-box;
}
.inputs {
text-align: center;
margin: 16px;
label {
cursor: pointer;
padding: 12px 0;
}
input {
cursor: pointer;
margin-left: 12px;
}
}
var $box = $('.box');
$('.inputs').find('input').on('change', function() {
console.log(this);
$box.css('background-clip', $(this).attr('id'));
});
This Pen doesn't use any external CSS resources.