I am trying to implement a custom style button like the image shown below using css. enter image description here

我在我的css文件中try 了这一点,我能够实现更接近所需设计的东西:

.casinoButton {
position: relative;
display: inline-block;
border: none;
color: white;
font-size: 14px;
width: 100%;
overflow: hidden;
cursor: pointer;
/* background-color: #ff0000;  */
border-radius: 40% 0 0 0; /* Creates a curved effect */ 

}

.casinoButton::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000000; /* Black color for the top-left corner */
border-radius: 50%;
z-index: -1;
transition: transform 0.3s ease;
transform: scale(0) translate(-50%, -50%);
transform-origin: top left;
}

.casinoButton:hover::before {
transform: scale(2) translate(-50%, -50%);
}


.liveCasinoButton {
  position: relative;
  display: inline-block;
  border: none;
  color: white;
  font-size: 14px;
  width: 100%;

  overflow: hidden;
  cursor: pointer;
  /* background-color: #2A2A2A; */
  border-radius: 0 40% 0 0; /* Creates a curved effect */
  }

 .liveCasinoButton::before {
   content: '';
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   background-color: #000000; /* Black color for the top-left corner */
   border-radius: 50%;
   z-index: -1;
   transition: transform 0.3s ease;
   transform: scale(0) translate(-50%, -50%);
   transform-origin: top left;
   }

.liveCasinoButton:hover::before {
  transform: scale(2) translate(-50%, -50%);
}

通过上面的代码,我能够实现如下所示的设计.但我想得到如第一张图片所示的按钮设计!

enter image description here

有人可以帮助我使用css,这样我就可以实现第一张图片中所需的设计!

推荐答案

您可以在父元素上使用CSS clip-path with ellipse()

.buttons-group {
  clip-path: ellipse(80% 100% at 50% 100%);
  display: flex;
  
  & button {
    flex: 1;
    background: hsl(355 94% 52%);
    color: hsl(0 0% 100%);
    border: 0;
    padding: 1.5rem;
    
    & +button {
      background: hsl(223 13% 21%);
    }
  }
}
<div class="buttons-group">
  <button type="button">CASINO</button>
  <button type="button">LIVE CASINO</button>
</div>

并将上面的椭圆第一个值(80%)更改为所需的百分比.

Css相关问答推荐

大型菜单的CSS动态布局,根据菜单项的数量以行或列形式读取

使用背景滤镜时,伪元素出现在div之前

使用高图的背景大小渐变

如何在横向和纵向布局上使用 CSS 网格中的纵横比来保持纵横比

创建一个CSS动画的对角线线条.

React Tabs 在 Tabs 之间垂直渲染标签内容

使用 place-content: center 的全宽 CSS 网格项目

没有字母间距的CSS悬停边框

如何在启动时滚动 div 的底部?

带有 flex 的 CSS 空 div 以扩展并保持纵横比

我怎样才能让我所有的网格列的高度等于最短列的高度

用于替代渲染的 CSS 嵌套

使用 styled-components,我如何定位组件的子类?

使用 display:inline-block 渲染多行文本组件,行间有白色间隙

当计算的宽度不准确时,如何在 cypress 中测试元素的宽度?

当我在几个月之间更改时,有什么方法可以在react-dates-range上添加淡入淡出或幻灯片效果?

如何通过单击
  • 激活 HTML 链接?
  • HTML表格:保持列的宽度相同

    background-position-x (background-position-y) 是标准的 W3C CSS 属性吗?

    如何将页脚(div)与页面底部对齐?