Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Created May 14, 2020 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojaray2k/f9ac03fa7bf6eff033711f5eaa004dad to your computer and use it in GitHub Desktop.
Save mojaray2k/f9ac03fa7bf6eff033711f5eaa004dad to your computer and use it in GitHub Desktop.
Square Patterns in CSS

Square Patterns in CC

nesting and centering squares

<!DOCTYPE html>
<html>
<head>
</head>
<body>
	<div class='outer-square'>
    <div class='first-inner-square'>
        <div class='second-inner-square'></div>
    </div>
    <div class='corner-square'>
    </div>
  </div>
</body>
</html>
.outer-square {
  width: 250px;
  height: 250px;
  background-color: red;
  position: relative;
}

.first-inner-square {
  width: 50%;
  height: 50%;
  background-color: green;
  position: absolute;
  top: 50%;
  left: 25%;
  transform: translateY(-50%);
  line-height: 300px;
  text-align: center;
  font-size: 0px;
}

.second-inner-square {
  width: 50%;
  height: 50%;
  font-size: 16px;
  display: inline-block;
  vertical-align: 55px;
  line-height: initial;
  text-align: left;
  margin-left: auto;
  margin-right: auto;

  background-color: yellow;
}

.corner-square {
  width: 25%;
  height: 25%;
  position: absolute;
  top: 87%;
  left: 75%;
  transform: translateY(-50%);
  background-color: blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment