Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
666 views
in Technique[技术] by (71.8m points)

css shapes - How to make angled tab like this using css?

I need to make like this. Is it possible with pure css?

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Using border-radius, :before and transform: skew(...);

body {
  background-color: #000;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  font-size: 16px;
}
.tab {
  height: 50px;
  width: 150px;
  border-radius: 15px 15px 0px 0px;
  background-color: #FFF;
  position: relative;
  top: 10px;
  left: 1px;
  display: inline-block;
  z-index: 2;
}
.tab:before {
  height: 50px;
  width: 70px;
  border-radius: 10px 10px 0px 0px;
  background-color: white;
  content: "";
  position: absolute;
  left: 104px;
  top: 0px;
  -webkit-transform: skewX(40deg);
  transform: skewX(40deg);
  z-index: -1;
}
.tab:nth-of-type(2) {
  background-color: #555;
  top: 10px;
  left: 30px;
  z-index: 1;
  color: #EEE;
}
.tab:nth-of-type(2):before {
  background-color: #555;
}
.tab:nth-of-type(2):hover,
.tab:nth-of-type(2):hover:before {
  background-color: #159;
  transition: 0.3s ease-out;
}
span {
  display: inline-block;
  width: 160px;
  text-align: center;
  height: 50px;
  line-height: 50px;
  z-index: 3;
}
#page {
  background-color: white;
  height: calc(100vh - 120px);
  width: calc(100vw - 61px);
  position: relative;
  top: 10px;
  left: 1px;
  padding: 30px;
}
<nav id="tabs">
  <div class="tab">
    <span>Tab 1</span>
  </div>
  <div class="tab">
    <span>Tab 2</span>
  </div>
</nav>
<div id="page">
  Lorem Ipsum dolor sit amet ...
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...