html - 如何沿边界半径剪辑内容?
问题描述
我正在构建一个具有特殊设计的聊天机器人,其中包括顶部的旋转 div。我想在边框周围剪裁我的标题分区。
在此示例中,我无法border-radius: 29px;
在班级的左上角和右上角维护我的聊天小部件header-part
。
请在这个问题上指导我。谢谢。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Chatbot</title>
<style>
.chatbot-main {
width: 431px;
height: 719px;
border-radius: 29px;
background-color: #f2f4f9;
margin: 20px
}
.header-part {
padding: 20px;
height: 125px;
background-color: #21f5a8;
border-top-left-radius: 29px;
border-top-right-radius: 29px;
border-bottom-left-radius: 26px;
border-bottom-right-radius: 26px;
clip-path: inset(0px 0px 0px 0px);
}
.company-header {
background-color: #0caa63;
display: block;
width: 453.3px;
height: 170px;
position: absolute;
left: 4px;
top: -85.38px;
transform: rotate(-2.86deg);
}
.support-header {
position: absolute;
top: 130px;
}
</style>
</head>
<body>
<div class="chatbot-main">
<div class="header-part">
<div class="company-header">Chatbot</div>
<div class="support-header">
you are talking to support assistant
</div>
</div>
</div>
</body>
</html>
解决方案
你只需要添加
overflow: hidden;
position: relative;
给你的.header-part
例子:
.chatbot-main {
width: 431px;
height: 719px;
border-radius: 29px;
background-color: #f2f4f9;
margin: 20px
}
.header-part {
padding: 20px;
height: 125px;
background-color: #21f5a8;
border-top-left-radius: 29px;
border-top-right-radius: 29px;
border-bottom-left-radius: 26px;
border-bottom-right-radius: 26px;
clip-path: inset(0px 0px 0px 0px);
overflow: hidden;
position: relative;
}
.company-header {
background-color: #0caa63;
display: block;
width: 453.3px;
height: 170px;
position: absolute;
left: 4px;
top: -85.38px;
transform: rotate(-2.86deg);
}
.support-header {
position: absolute;
top: 130px;
}
<div class="chatbot-main">
<div class="header-part">
<div class="company-header">Chatbot</div>
<div class="support-header">
you are talking to support assistant
</div>
</div>
</div>
推荐阅读
- php - Filetype() 和 is_dir() 显示不同的结果
- python - 如何使用 Pandas/Matplotlib 在 X 轴上绘制日期,在 Y 轴上绘制时间,并以 HH:MM 格式显示时间作为刻度标签?
- github - Github 页面:页面构建失败,#troubleshooting-build-errors
- laravel - 如何在 Laravel 中进行 Facebook 身份验证后重定向给定、正确和干净的 URL?
- reactjs - 在 reactjs 应用程序中获取 Jscript 编译错误
- python - 返回熊猫中指定值的列名
- ssl-certificate - SSL 免费,托管 App infinityfree 不工作
- amazon-web-services - JDBC读/写中的火花时间戳时区
- ruby-on-rails - 如何通过 id 选择商店库存中不存在的产品
- java - 在 js/php 范围内有什么更好的选择/目标概念