Pure CSS3 Ribbons

特别声明:如果您喜欢小站的内容,可以点击年卡¥199.00元(原价: ¥598元)季卡¥78.00元(原价: ¥168元)月卡¥28.00元(原价: ¥68元)进行全站阅读。如果您对付费阅读有任何建议或想法,欢迎发送邮件至: airenliao@gmail.com!或添加QQ:874472854(^_^)

前面在CSS3 Ribbons一文中介绍了一个纯CSS3制作的“Ribbons”效果,今天收集了更多的“Ribbons”效果,以供大家参考与学习,希望大家能喜欢。

在看具体每个demo之前,我们一起来看下面一个截图:

上图是一个典型的“Ribbons”各部位的示意图,但每一个“Ribbons”并不会都使用上图示意的各个部分,在下面的实例中大家可以明显的看到或者说感受到。别的我就不多说了,我想上图能示意出“Ribbons”各个部位。那么每个部位我们可以使用一个“html”标签,当然有了CSS3的伪元素“::before”和“::after”后,我们可以省去一些标签。

效果一:

HTML Markup

	<div class="ribbons" id="ribbon-1">Ribbon-1</div>
	

CSS Code

		#ribbon-1 {
				font: bold 16px/48px Cambria,Georgia,Times,serif;
				color: #000;
				text-shadow: 1px 0 0 hsla(20,50%,30%,0.6);
				width: 300px;
				padding: 0 0 0 30px;
				background: hsla(200, 20%, 80%, 0.8);
				position: relative;
			}
			#ribbon-1::after {
				content: "";
				position: absolute;
				top: 0;
				left: 100%;
				width: 0;
				height: 0;
				border: 24px solid hsla(200, 20%, 80%, 0.8);
				border-right-color: transparent;
			}
	

DEMO效果

效果二

HTML Markup

		<div class="ribbons" id="ribbon-2">Ribbon-2</div>
	

CSS Code

		#ribbon-2 {
			font: bold 16px/48px Cambria,Georgia,Times,sans-serif;
			color:hsla(25,50%,80%,1);
			text-shadow: 1px 0 0 hsla(20,50%,30%,0.6);
			width: 300px;
			position: relative;
			background: hsla(255,45%,50%,0.8);
		}
		#ribbon-2::before {
			content:"";
			position: absolute;
			top:0;
			right: 100%;
			width: 0;
			height: 0;
			border: 24px solid hsla(255,45%,50%,0.8);
			border-left-color:transparent;
		}
		#ribbon-2::after {
			content:"";
			position:absolute;
			top:0px;
			left: 100%;
			width:0;
			height:0;
			border:24px solid transparent;
			border-left-color: hsla(255,45%,50%,0.8);
		}
	

DEMO效果:

效果三

HTML Markup

		<div class="ribbons" id="ribbon-3">Ribbon-3</div>
	

CSS Code

		#ribbon-3 {
			font: bold 16px/48px Cambria,Georgia,Times,serif;
			color: hsla(100,80%,20%,0.6);
			text-shadow: 1px 0 0 hsla(20,50%,30%,0.6);
			width: 300px;
			padding: 0 0 0 30px;
			position: relative;
			background: hsla(200,80%,50%,0.8);
		}
		#ribbon-3::before {
			content:"";
			position: absolute;
			top:100%;
			left:0px;
			width:0;
			height: 0;
			border: 5px solid transparent;
			border-color: hsla(200,70%,42%,0.8) hsla(200,70%,42%,0.8) transparent transparent;
		}
		#ribbon-3::after {
			content:"";
			position: absolute;
			top:0;
			left: 100%;
			width:0;
			height: 0;
			border: 24px solid hsla(200,80%,50%,0.8);
			border-right-color: transparent;	
		}
	

DEMO效果:

效果四

HTML Markup

		<div class="ribbons" id="ribbon-4">Ribbon-4</div>
	

CSS Code

		#ribbon-4 {
			font: bold 16px Cambria,Georgia,Times,serif;
			line-height: 48px;
			width: 315px;
			padding: 0 30px;
			position: relative;
			text-align: center;
			color: hsla(180,60%,80%,0.8);
			text-shadow: 1px 0 0 hsla(20,50%,30%,0.6);
			background: hsla(20,30%,30%,0.8);
		}
		#ribbon-4::before {
			content:"";
			position: absolute;
			top: 100%;
			left:0;
			width: 0;
			height: 0;
			border: 5px solid transparent;
			border-color: hsla(20,25%,25%,0.85) hsla(20,25%,25%,0.85) transparent transparent;
		}
		#ribbon-4::after {
			content:"";
			position: absolute;
			top: 100%;
			right: 0;
			width: 0;
			height: 0;
			border: 5px solid transparent;
			border-color: hsla(20,25%,25%,0.85) transparent transparent hsla(20,25%,25%,0.85);
		}
	

DEMO效果:

效果五

HTML Markup

		<div id="ribbon-5-wrap">
			<div class="ribbons" id="ribbon-5">
				<div>Ribbon-5</div>
			</div>
		</div>
	

CSS Code

		#ribbon-5-wrap {
			position: relative;
			z-index: 1;
		}
		#ribbon-5 {
			font: bold 16px Cambria,Georgia,Times,serif;
			line-height: 48px;
			width: 300px;
			padding: 0 30px;
			position: relative;
			color: hsla(350,80%,30%,0.8);
			text-shadow: 1px 0 0 hsla(20,50%,30%,0.6);
			background: hsla(315,40%,60%,1);
			text-align: center;
		}
		#ribbon-5::before {
			content:"";
			position:absolute;
			top:100%;
			left:0;
			width:0;
			height:0;
			border: 5px solid transparent;
			border-color: hsla(315,28%,50%,0.95) hsla(315,28%,50%,0.95) transparent transparent;
		}
		#ribbon-5::after {
			content:"";
			position:absolute;
			top:100%;
			right:0;
			width:0;
			height:0;
			border: 5px solid transparent;
			border-color: hsla(315,28%,50%,0.95) transparent transparent hsla(315,28%,50%,0.95);
		}
		#ribbon-5 > div {
			width: 100%;
		}
		#ribbon-5 > div::before,
		#ribbon-5 > div::after {
			content:"";
			position: absolute;
			width: 0;
			height:0;
			border: 24px solid hsla(315,23%,40%,0.95);
			top:10px;
			z-index: -1;
		}
		#ribbon-5 > div::before {
			border-left-color: transparent;
			right: 100%;
			margin-right: -10px;
		}
		#ribbon-5 > div::after {
			border-right-color: transparent;
			left: 100%;
			margin-left: -10px;
		}
	

DEMO效果:

效果六

HTML Markup

		<div class="ribbons" id="ribbon-6">Ribbon-6</div>
	
剩余80%内容付费后可查看

如需转载,烦请注明出处:https://www.w3cplus.com/css3/pure-css3-ribbons

如果文章中有不对之处,烦请各位大神拍正。如果你觉得这篇文章对你有所帮助,打个赏,让我有更大的动力去创作。(^_^)。看完了?还不过瘾?点击向作者提问!

赏杯咖啡,鼓励他创作更多优质内容!
返回顶部