Rectangle with curved sides [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-13 11:23:27

问题


How can I achieve this by simple DIV with css?

HTML:

<div class="curv">
    <div class="holder"></div>
</div>

CSS:

.curv{
    width: 800px;
    margin: 0 auto;
    position: relative;
    padding-top: 100px;
    overflow: hidden;
}
.curv:before{
    background: #333;
    width: 100%;
    height: 200px;
    left: 0px;
    right: 0px;
    top: 0px;
    content: '';
    position: absolute;
    border-radius: 100% 100% 0 0;
}
.holder{
    width: 100%;
    height: 200px;
    background: #333;
    position: relative;
    z-index: 9999;
}

What I am getting now is: https://jsfiddle.net/debraj/fnL3wzrn/

I want to look the corners to be sharp edges and not smooth. So it will look like this:


回答1:


Please check updated code

.curv{
    width: 800px;
    margin: 0 auto;
    position: relative;
    padding-top: 100px;
    overflow: hidden;
}
.curv:before{
    background: #333;
    height: 200px;
    left: -20px;
    right: -20px;
    top: 10px;
    content: '';
    position: absolute;
    border-radius: 100% 100% 0 0;
}
.holder{
     height: 200px;
    background: #333;
    position: relative;
    z-index: 9999;
}
<div class="curv">
    <div class="holder"></div>
</div>


来源:https://stackoverflow.com/questions/28860810/rectangle-with-curved-sides

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!