Double left and right buttons with a corner in the middle

Watch this image

Facebook Messenger Android Application Buttons (MESSENGER \ ACTIVE)

How can I achieve this?

in detail: -

A div with 2px red border. that div contains 2 buttons with a built-in block. one is on the left side and the other is on the right side of the DIV. LIKE: [BUTTON1] [BUTTON2] but I want this: - [BUTTON1 \ BUTTON2] a slash style form is used between the two buttons.

I tried

#M_Left {
  width: 0;
  height: 0;
  margin: 0 !important;
  padding: 0 !important;
  display: inline-block;
  border-top: 100px solid #3fc2ff;
  border-right: 50px solid transparent;
  border-left: 400px solid #3fc2ff;
  color: #fff;
  text-align: center;
}

#M_Right {
  width: 0;
  height: 0;
  margin-left: -40;
  border-bottom: 100px solid #3fc2ff;
  display: inline-block;
  border-right: 400px solid #3fc2ff;
  border-left: 50px solid transparent;
  color: #fff;
  text-align: center !important;
}

.white_M {
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  display: inline-block;
  min-width: 400px;
  border-width: 0 !important;
  border-style: none !important;
  color: #3fc2ff !important;
}

.M_Container {
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  display: inline-block;
  border: 2px solid #3fc2ff;
}
<div class="M_Container">
  <div id="M_Left"> HEY</div>
  <div id="M_Right" class="white_Mx"> </div>
</div>
Run codeHide result

Please help me thank you in advance

+4
source share
2 answers

Try it.

$('button').click(function() {
  $('button').removeClass('active');
  $(this).addClass('active');
})
.wrap {
  white-space: nowrap;
  font-size: 0;
  border: 2px solid navy;
  display: inline-block;
  overflow: hidden;
}

button {
  border: 0;
  background: #fff;
  padding: 10px 20px;
  position: relative;
  outline: 0;
  cursor:pointer;
}

button:after,
button:before {
  content: '';
  position: absolute;
  transform: skewX(-25deg);
  height: 100%;
  width: 10px;
  background: #fff;
  top: 0;
  z-index: 1;
  right: 0;
}

button:before {
  right: auto;
  left: 0;
}

button.active {
  background: blue;
  color: #fff;
}

button.active:after,
button.active:before {
  background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrap">
  <button>Button</button>
  <button class="active">Active</button>
</div>
Run codeHide result
+2
source

You can create it using the following approach

$('button').click(function() {
  $(this).addClass('current').siblings().removeClass('current');
});
.buttonGroup {
  display: flex;
  border: 1px solid skyblue;
  /* Border color change as your need */
  overflow: hidden;
  border-radius: 5px;
  max-width: 350px;
}

button {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 5px;
  cursor: pointer;
  position: relative;
}

button:hover:before {
  background: skyblue;
}

button:hover:after {
  background: skyblue;
}

button.current:before {
  background: skyblue;
}

button.current:after {
  background: skyblue;
}

button:before {
  content: '';
  width: 100%;
  height: 100%;
  background: #fff;
  position: absolute;
  transform: skewX(-25deg);
  left: -5px;
  top: 0;
  z-index: -1;
}

button:after {
  content: '';
  width: 100%;
  height: 100%;
  background: #fff;
  position: absolute;
  transform: skewX(-25deg);
  right: -5px;
  top: 0;
  z-index: -1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="buttonGroup">
  <button>Hello</button>
  <button>Bye</button>
</div>
Run codeHide result
+4
source

Source: https://habr.com/ru/post/1681246/


All Articles