首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用CSS使菱形形状的角变圆?

如何使用CSS使菱形形状的角变圆?
EN

Stack Overflow用户
提问于 2020-10-14 21:50:11
回答 1查看 379关注 0票数 1

我在试着让this UI

为了制作这个上部的蓝色容器,我使用了裁剪路径方法。

你能告诉我如何在医生图像后面添加菱形形状并使其在右下角变圆吗?

代码语言:javascript
运行
复制
*{
    margin: 0px;
    padding: 0px;
}
.data{
    /* background-color: yellow; */
    width: 40%;
    padding-top: 63px;
    padding-left: 29px;
}
ul{
    display: flex;
    list-style: none;
    
}
li{
    margin: 10px;
}
.nav{
    /* float: right; */
    margin-right: 37%;
   display: flex;
   align-items: center;
    justify-content: space-between;
}
button{
    border-radius: 10px;
    color: #03A9F4;
    border: none;
    padding: 8px;
}

#logo{
    height: 54px;border-bottom-right-radius: 15px;}

#title{
    font-size: 53px;
    font-weight: bold;
}

#subtitle{
    font-size: 1.5rem;
    font-weight: bold;
}
#about{
    margin-top: 10px;
    margin-bottom: 10px;
}
#doctor{
    position: absolute;
    left: 47%;
    top: 15%;
}
#body{
background-image: url("../assets/back.png");
height: 100vh;
width: 100wh;
background-size: cover;
background-repeat: no-repeat;
}


.home {
    
    background: #03A9F4;
    width: 100%;
    color: white;
    height: 65vh;
    clip-path: polygon(0% 0%,65% 0%,43% 100%,0% 100%);
    }
代码语言:javascript
运行
复制
<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="home.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
 <div id="body">
    <div class="home">
        <div class="nav">
           <div id="logo"><img  src="../assets/logo (3).png" alt=""/></div>
            <ul>
               <li>Home</li>         
               <li>About Us</li>         
               <li>Contact Us</li>
           </ul>
        </div>
     <div class="data">
       <div id="title">Best Doctor</div>
       <div id="subtitle">Best Treatment</div>
       <div id="about">Lorem Ipsum is simply dummy text of the printing and typesetting industry.It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged</div>
       <button>Search Doctor</button>
   </div>
    </div>    
    <div id="doctor"> <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcT7TMH4j7DUVZmCNB-7mt9cRDRUGXJKyUbxYw&usqp=CAU" alt="">>
    </div> 
 </div>
</body>
</html>

EN

Stack Overflow用户

发布于 2020-10-14 22:05:17

代码语言:javascript
运行
复制
img {
  transform:rotate(-45deg);
  position:absolute;
  top:-25%;
  left:-25%;
}

div {
  width: 100px;
  height: 100px;
  transform:rotate(45deg);
  overflow: hidden;
  border-radius: 10px;

  /* Position away from the corner: */
  position: absolute;
  top: 50px;
  left: 50px;
}
代码语言:javascript
运行
复制
<div>
<img width="150px" height="150px" src="https://img.freepik.com/free-vector/doctor-character-background_1270-84.jpg?size=338&ext=jpg">
</div>

它的工作原理是从div中创建一个rombus形状,在其中定位一个图像,并对其进行裁剪。

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64354784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档