Material Box

Material Box

WEB Design & Material Images

CSS - Line Graph Icon

CSS

Code example for drawing a simple line graph icon using HTML and CSS.


The HTML code sets the class name "line-graph-icon" for the <div> tag which will make up the line graph icon element.
The frame and bars of the graph are set up using the <div> tag.

<div class="line-graph-icon">
	<div></div><div></div><div></div><div></div>
</div>

The CSS custom properties:
"--w" sets the base size.
"--color" sets the base color.

The graph bars use rotate() positioned from the center start point.

/* Line Graph Icon */
.line-graph-icon {
	--w: 300px; /* Base size */
	--color: #00fa9a; /* Base color */
	position: relative;
	width: var(--w);
	height: var(--w);
}

/* Frame */
.line-graph-icon div:nth-child(1) {
	position: absolute;
	top: 5%;
	left: 5%;
	width: 90%;
	height: 90%;
	border: solid calc(var(--w) * 0.08) var(--color);
	border-top: 0;
	border-right: 0;
	box-sizing: border-box;
}

/* Bar A */
.line-graph-icon div:nth-child(2) {
	position: absolute;
	top: 25%;
	left: 20%;
	width: 4%;
	height: 45%;
	background: var(--color);
	transform-origin: center bottom;
	transform: rotate(25deg);
}

.line-graph-icon div:nth-child(2)::before {
	content: "";
	position: absolute;
	top: calc(var(--w) * 0.3);
	left: calc(var(--w) * (-0.05));
	width: calc(var(--w) * 0.15);
	height: calc(var(--w) * 0.15);
	background-color: var(--color);
	border-radius: 50%;
}

.line-graph-icon div:nth-child(2)::after {
	content: "";
	position: absolute;
	top: calc(var(--w) * (-0.02));
	left: calc(var(--w) * (-0.04));
	width: calc(var(--w) * 0.15);
	height: calc(var(--w) * 0.15);
	background-color: var(--color);
	border-radius: 50%;
}

/* Bar B */
.line-graph-icon div:nth-child(3) {
	position: absolute;
	top: 30%;
	left: 38%;
	width: 4%;
	height: 40%;
	background: var(--color);
	transform-origin: center top;
	transform: rotate(-25deg);
}

.line-graph-icon div:nth-child(3)::before {
	content: "";
	position: absolute;
	top: calc(var(--w) * 0.3);
	left: calc(var(--w) * (-0.04));
	width: calc(var(--w) * 0.15);
	height: calc(var(--w) * 0.15);
	background-color: var(--color);
	transform-origin: center bottom;
	border-radius: 50%;
}

/* Bar C */
.line-graph-icon div:nth-child(4) {
	position: absolute;
	top: 15px;
	left: 56%;
	width: 4%;
	height: 55%;
	background: var(--color);
	transform-origin: center bottom;
	transform: rotate(25deg);
}

.line-graph-icon div:nth-child(4)::after {
	content: "";
	position: absolute;
	top: calc(var(--w) * (-0.05));
	left: calc(var(--w) * (-0.04));
	width: calc(var(--w) * 0.15);
	height: calc(var(--w) * 0.15);
	background-color: var(--color);
	transform-origin: center bottom;
	border-radius: 50%;
}

CSS - Line Graph Icon

TitleCSS - Line Graph Icon

CategoryCSS

Created

Update

AuthorYousuke.U