htunc
htunc

Reputation: 475

How to create an oval rectangle with css?

I'd like to create an oval rectangle with css. I know i can do it with border-radius but i'd like to do something like that:

enter image description here

Is there any way to do it with pure css?

Upvotes: 1

Views: 456

Answers (1)

htunc
htunc

Reputation: 475

Did it, if someone needs.

.oval-rectangle {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  width: 150px;
  height: 150px;
  position: relative;
  margin: 20px 0;
  border: none;
  -webkit-border-radius: 50% / 10%;
  border-radius: 50% / 10%;
  text-align: center;
  text-indent: 0.1em;
  -o-text-overflow: clip;
  text-overflow: clip;
  background: #1abc9c;
}

.oval-rectangle::before {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  position: absolute;
  content: "";
  top: 10%;
  right: -5%;
  bottom: 10%;
  left: -5%;
  border: none;
  -webkit-border-radius: 5% / 50%;
  border-radius: 5% / 50%;
  -o-text-overflow: clip;
  text-overflow: clip;
  background: #1abc9c;
  text-shadow: none;
}
<div class="oval-rectangle"></div>

Upvotes: 1

Related Questions