Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Make Square Corner Things? [closed]

Tags:

css

Really vague question, I know, but I don't know how to describe them... Basically, I want these:

What I want

I'm talking about the corner things in red. What's the easiest way to achieve this? Obviously, you could just make individual divs in those shapes, but I feel like getting them in the positions you want, even when everything re-sizes and stuff, would be a pain. Is that the only way?

like image 620
Tommay Avatar asked Jul 20 '15 23:07

Tommay


People also ask

What is the 3 4 5 rule for squaring corners?

To get a perfectly square corner, you want to aim for a measurement ratio of 3:4:5. In other words, you want a three-foot length on your straight line, a four-foot length on your perpendicular line, and a five-foot length across. If all three measurements are correct, you'll have a perfectly square corner.


1 Answers

Here an approach that might be useful. Add two pseudo elements, one with top and bottom borders and the second with left and right borders of a certain color (white) such that they "white out" the original border (blue in this case).

This approach is pure CSS and no extra mark-up is involved.

div {
  font-size: 4.00em;
  padding: 40px;
  border: 2px solid blue;
  display: inline-block;
  position: relative;
}
div:after {
  content: '';
  display: block;
  border-left: 2px solid white;
  border-right: 2px solid white;
  position: absolute;
  height: 50%;
  left: -2px;
  right: -2px;
  top: 25%;
  bottom: 25%;
}
div:before {
  content: '';
  display: block;
  border-top: 2px solid white;
  border-bottom: 2px solid white;
  position: absolute;
  height: 100%;
  left: 25%;
  right: 25%;
  top: -2px;
  bottom: -2px;
}
<div>Box Text</div>
like image 97
Marc Audet Avatar answered Sep 22 '22 17:09

Marc Audet