有关如何使用纯css3创建类似内容的任何想法吗?
答案 0 :(得分:3)
你可以单独用css做这件事 只需使用< div> 标记并设置颜色和位置即可创建形状。
.container {
background-color: #ddd;
border-radius: 15px;
width: 200px;
height: 75px;
position: relative;
}
.container div {
position: relative;
display: inline-block;
top: 25%;
width: 7%;
height: 40%;
margin: 2%;
background-color: black;
}
.container div:nth-of-type(1) {
margin-left: 7%;
background-color: red;
}
.container div:nth-of-type(2) {
background-color: firebrick;
}
.container div:nth-of-type(3) {
background-color: Orange;
}
.container div:nth-of-type(4) {
background-color: yellow;
}
.container div:nth-of-type(5) {
background-color: LightGreen;
}
.container div:nth-of-type(6) {
background-color: ForestGreen;
}
.container div:nth-of-type(7) {
background-color: green;
}

<div class="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
&#13;
答案 1 :(得分:2)
这样的事情怎么样?
.container{
width:500px;
height:100px;
overflow:hidden;
}
.secondary{
width:500px;
height:100px;
transform:rotate(-5deg);
transform-origin:100% 100%;
overflow:hidden;
}
.prgbr{
width:50px;
height:100px;
transform:rotate(5deg);
display:inline-block;
margin-top:-5px;
}
.prgbr:nth-child(1){
background:red;
}
.prgbr:nth-child(2){
background:red;
}
.prgbr:nth-child(3){
background:orange;
}
.prgbr:nth-child(4){
background:orange;
}
.prgbr:nth-child(5){
background:yellow;
}
.prgbr:nth-child(6){
background:lightgreen;
}
.prgbr:nth-child(7){
background:green;
}
<div class="container">
<div class="secondary">
<div class="prgbr"></div>
<div class="prgbr"></div>
<div class="prgbr"></div>
<div class="prgbr"></div>
<div class="prgbr"></div>
<div class="prgbr"></div>
<div class="prgbr"></div>
</div>
</div>
答案 2 :(得分:2)
虽然这可能需要一点点的修补,但你可以使用类似的东西:
$('#add').click(function() {
var x = parseInt($('.ran').val()) + 1;
$('.ran').attr('value', x);
});
$('#min').click(function() {
var x = parseInt($('.ran').val()) - 1;
$('.ran').attr('value', x);
});
html,body{margin:0;padding:0;background:#222; text-align:center;}
.onetoTen {
height: 100px;
width: 300px;
overflow: hidden;
position: relative;
background:lightgray;
padding:10px;
padding-bottom:0;
border-radius:10px;
border:5px solid dimgray;
margin: 20px auto;
}
.onetoTen div {
display: inline-block;
width: 9%;
height: 100%;
transform: skewY(-20deg);
transform-origin: bottom right;
vertical-align: bottom;
position: absolute;
bottom: 0;
}
.ran {
display: none;
}
.ran[value="0"] + .onetoTen div {
display: none;
}
.ran[value="1"] + .onetoTen div:nth-child(1) ~ div {
display: none;
}
.ran[value="2"] + .onetoTen div:nth-child(2) ~ div {
display: none;
}
.ran[value="3"] + .onetoTen div:nth-child(3) ~ div {
display: none;
}
.ran[value="4"] + .onetoTen div:nth-child(4) ~ div {
display: none;
}
.ran[value="5"] + .onetoTen div:nth-child(5) ~ div {
display: none;
}
.ran[value="6"] + .onetoTen div:nth-child(6) ~ div {
display: none;
}
.ran[value="7"] + .onetoTen div:nth-child(7) ~ div {
display: none;
}
.ran[value="8"] + .onetoTen div:nth-child(8) ~ div {
display: none;
}
.ran[value="9"] + .onetoTen div:nth-child(9) ~ div {
display: none;
}
.ran[value="10"] + .onetoTen div:nth-child(10) ~ div {
display: none;
}
.onetoTen div:nth-child(1) {
left: 0;
height: 10%;
background: rgb(255, 0, 0)
}
.onetoTen div:nth-child(2) {
left: 10%;
height: 20%;
background: rgb(235, 0, 25)
}
.onetoTen div:nth-child(3) {
left: 20%;
height: 30%;
background: rgb(215, 0, 45)
}
.onetoTen div:nth-child(4) {
left: 30%;
height: 40%;
background: rgb(195, 0, 65)
}
.onetoTen div:nth-child(5) {
left: 40%;
height: 50%;
background: rgb(175, 0, 85)
}
.onetoTen div:nth-child(6) {
left: 50%;
height: 60%;
background: rgb(155, 0, 115)
}
.onetoTen div:nth-child(7) {
left: 60%;
height: 70%;
background: rgb(125, 0, 135)
}
.onetoTen div:nth-child(8) {
left: 70%;
height: 80%;
background: rgb(105, 0, 155)
}
.onetoTen div:nth-child(9) {
left: 80%;
height: 90%;
background: rgb(85, 0, 175)
}
.onetoTen div:nth-child(10) {
left: 90%;
height: 100%;
background: rgb(0, 0, 255)
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="ran" value="1" type="progress" min="0" max="10" />
<div class="onetoTen">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<button id="add">Add</button>
<button id="min">minus</button>
请注意我的答案中包含的JQuery我确信可以改进,因此仅用于演示目的(因为它需要包含验证规则)