html - 如何在矩形右侧创建新月边界半径?
问题描述
我正在尝试创建这样的按钮
我只是不知道要搜索什么来创建这样的形状。
这是迄今为止我所拥有的。
.rectangle {
height: 50px;
width: 200px;
background-color: #555;
border-radius: 10px 0px 0px 10px;
}
.radius_rectangle {
width: 90px;
background: red;
height: 50px;
border-radius: 0px 40px 40px 0px;
}
<div class="rectangle">
<div class="radius_rectangle">
</div>
</div>
如果有人可以帮助我,我将不胜感激。
解决方案
您快到了。设置overflow:hidden
为.rectangle
,注意border-radius
角落。你还需要.radius_rectangle
向右移动——我用过margin-left:auto
. 另一种方法是设置text-align:right
为.rectangle
。
.rectangle {
height: 50px;
width: 200px;
overflow: hidden;
background: #555;
border-radius: 40px 0 0 40px;
box-shadow: 0 0 3px 0 #000;
}
.radius_rectangle {
width: 130px;
height: 50px;
margin-left: auto;
background: #fff;
border-radius: 40px 0 0 40px;
}
<div class="rectangle">
<div class="radius_rectangle"></div>
</div>
推荐阅读
- php - 如何使用数据库密码保护 php 连接文件
- cuda - __activemask() 与 __ballot_sync()
- laravel-5 - 如何在 vuejs 中使用多维复选框 v-model
- javascript - Firebase 和 React js - Firebase:名为“[DEFAULT]”的 Firebase 应用程序已存在(应用程序/重复应用程序)
- python - Pandas:将数组列读取为列(字符串数组)
- python - 使用 pandas 样式突出显示单个列
- c# - 仅在条件发生时触发的事件
- reactjs - 如何将 webpack 与 create-react-app 一起使用?
- linux - 参数传递到文件读取为 0
- android - 所有 Anko 引用都是未定义的