CSS代码:
.stripes {
height: 250px;
width: 375px;
float: left; margin: 10px; -webkit-background-size: 50px 50px;
-moz-background-size: 50px 50px;
background-size: 50px 50px; /* 控制条纹的大小 */ -moz-box-shadow: 1px 1px 8px gray;
-webkit-box-shadow: 1px 1px 8px gray;
box-shadow: 1px 1px 8px gray;
} .horizontal {
background-color: #0ae;
background-image: -webkit-gradient(linear, , %, color-stop(., rgba(, , , .)), color-stop(., transparent), to(transparent));
background-image: -moz-linear-gradient(rgba(, , , .) %, transparent %, transparent);
background-image: -o-linear-gradient(rgba(, , , .) %, transparent %, transparent);
background-image: linear-gradient(rgba(, , , .) %, transparent %, transparent);
} .vertical {
background-color: #f90;
background-image: -webkit-gradient(linear, , % , color-stop(., rgba(, , , .)), color-stop(., transparent), to(transparent));
background-image: -moz-linear-gradient(0deg, rgba(, , , .) %, transparent %, transparent);
background-image: -o-linear-gradient(0deg, rgba(, , , .) %, transparent %, transparent);
background-image: linear-gradient(0deg, rgba(, , , .) %, transparent %, transparent);
} .picnic {
background-color:white;
background-image: -webkit-gradient(linear, , %, color-stop(., transparent), color-stop(., rgba(, , , .)), to(rgba(, , , .))),
-webkit-gradient(linear, , % , color-stop(., transparent), color-stop(., rgba(, , , .)), to(rgba(, , , .)));
background-image: -moz-linear-gradient(transparent %, rgba(, , , .) %, rgba(, , , .)),
-moz-linear-gradient(0deg, transparent %, rgba(, , , .) %, rgba(, , , .));
background-image: -o-linear-gradient(transparent %, rgba(, , , .) %, rgba(, , , .)),
-o-linear-gradient(0deg, transparent %, rgba(, , , .) %, rgba(, , , .));
background-image: linear-gradient(transparent %, rgba(, , , .) %, rgba(, , , .)),
linear-gradient(0deg, transparent %, rgba(, , , .) %, rgba(, , , .));
} .angled {
background-color: #ac0;
background-image: -webkit-gradient(linear, %, % ,
color-stop(., rgba(, , , .)), color-stop(., transparent),
color-stop(., transparent), color-stop(., rgba(, , , .)),
color-stop(., rgba(, , , .)), color-stop(., transparent),
to(transparent));
background-image: -moz-linear-gradient(45deg, rgba(, , , .) %, transparent %,
transparent %, rgba(, , , .) %, rgba(, , , .) %,
transparent %, transparent);
background-image: -o-linear-gradient(45deg, rgba(, , , .) %, transparent %,
transparent %, rgba(, , , .) %, rgba(, , , .) %,
transparent %, transparent);
background-image: linear-gradient(45deg, rgba(, , , .) %, transparent %,
transparent %, rgba(, , , .) %, rgba(, , , .) %,
transparent %, transparent);
} .angled- {
background-color: #c16;
background-image: -webkit-gradient(linear, , % %,
color-stop(., rgba(, , , .)), color-stop(., transparent),
color-stop(., transparent), color-stop(., rgba(, , , .)),
color-stop(., rgba(, , , .)), color-stop(., transparent),
to(transparent));
background-image: -moz-linear-gradient(-45deg, rgba(, , , .) %, transparent %,
transparent %, rgba(, , , .) %, rgba(, , , .) %,
transparent %, transparent);
background-image: -o-linear-gradient(-45deg, rgba(, , , .) %, transparent %,
transparent %, rgba(, , , .) %, rgba(, , , .) %,
transparent %, transparent);
background-image: linear-gradient(-45deg, rgba(, , , .) %, transparent %,
transparent %, rgba(, , , .) %, rgba(, , , .) %,
transparent %, transparent);
} .checkered {
background-image: -webkit-gradient(linear, , % %, color-stop(., #), color-stop(., transparent), to(transparent)),
-webkit-gradient(linear, %, % , color-stop(., #), color-stop(., transparent), to(transparent)),
-webkit-gradient(linear, , % %, color-stop(., transparent), color-stop(., #)),
-webkit-gradient(linear, %, % , color-stop(., transparent), color-stop(., #));
background-image: -moz-linear-gradient(45deg, # %, transparent %, transparent),
-moz-linear-gradient(-45deg, # %, transparent %, transparent),
-moz-linear-gradient(45deg, transparent %, # %),
-moz-linear-gradient(-45deg, transparent %, # %);
background-image: -o-linear-gradient(45deg, # %, transparent %, transparent),
-o-linear-gradient(-45deg, # %, transparent %, transparent),
-o-linear-gradient(45deg, transparent %, # %),
-o-linear-gradient(-45deg, transparent %, # %);
background-image: linear-gradient(45deg, # %, transparent %, transparent),
linear-gradient(-45deg, # %, transparent %, transparent),
linear-gradient(45deg, transparent %, # %),
linear-gradient(-45deg, transparent %, # %);
}
HTML代码:
<div class="horizontal stripes"></div>
<div class="vertical stripes"></div>
<div class="picnic stripes"></div>
<div class="angled stripes"></div>
<div class="angled-135 stripes"></div>
<div class="checkered stripes"></div>
来源:https://www.zhangxinxu.com/study/201104/css3-strips-patterns-no-image.html