简体   繁体   English

如何在纯HTML和CSS中制作此形状?

[英]How do I make this shape in pure HTML and CSS?

Here's a Codepen of what I currently have in my attempt to recreate this shape, and here's what I'm trying to make it look like the image below. 这是我目前在尝试重新创建此形状时所拥有的Codepen ,这是我正在尝试使其看起来像下面的图像。 I'm not certain how to make the bottom of the box look rounded, and box-radius does not seem sufficient. 我不确定如何使盒子的底部看起来很圆,并且盒子半径似乎还不够。

I've pasted my mark-up below for posterity. 我在后边粘贴了我的标记。

<div id="DIV_1">
<a href="#close" id="A_2">×</a>
<div id="DIV_3">
    <div id="DIV_4">
        <b id="B_5">13</b> min
    </div>
</div>
<div id="DIV_6">
    <div id="DIV_7">
    </div>
</div>

在此处输入图片说明

The basic idea: 基本思路:

2 main shapes, #one to create top-div, just set height and border-radius. 2个主要形状,#one用来创建顶级,只设置高度和边界半径。 and #two has 3 divs to create the side's (.skippy's) and the bubble into the middle to create the bubble.. #two具有3个div来创建侧面(.skippy),并在中间插入气泡以创建气泡。

Set height of #two not more than 2/3 of skippy's and you will be fine. 将#two的高度设置为不超过skippy的2/3,就可以了。

this is a basic scrats.. don't use it.. use it to create your own :p 这是基本的方法。.不要使用它..使用它来创建自己的:p

 #one { -webkit-border-radius: 60px; -moz-border-radius: 60px; border-radius: 60px; height: 200px; width: 500px; background-color: pink; } #two { width: 500px; height: 100px; background-color: pink; } .bubble { -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; background-color: pink; width: 100px; float: left; height: 150px; } .skippy1, .skippy2 { background-color: white; width: 200px; float: left; height: 150px; } .skippy2 { -webkit-border-top-left-radius: 100px; -moz-border-radius-topleft: 100px; border-top-left-radius: 100px; } .skippy1 { -webkit-border-top-right-radius: 100px; -moz-border-radius-topright: 100px; border-top-right-radius: 100px; } 
 <div id="one">&nbsp;</div> <div id="two"> <div class="skippy1 skippy">&nbsp;</div> <div class="bubble">&nbsp;</div> <div class="skippy2 skippy">&nbsp;</div> </div> 

EDIT (asker ask for more stuff, transparent etc..): you make a holder: set width place 2 divs,#one for top-div, #two to create the bubble... 编辑(问问要求更多的东西,透明的等等。):您制作一个支架:将宽度放置2格,将#div设置为上格,#2来创建气泡...

 #holder { width: 500px; background-color: red; } #one { -webkit-border-radius: 60px; -moz-border-radius: 60px; border-radius: 60px; height: 200px; background-color: pink; } #two { margin: auto; position: relative; top: -30px; width: 0; height: 0; border-left: 70px solid transparent; border-right: 70px solid transparent; border-top: 100px solid pink; } 
 <div id="holder"> <div id="one">&nbsp;</div> <div id="two">&nbsp;</div> </div> 

EDIT: prev was not what was asking.. 编辑:上一页不是在问什么..

Same for one as always... (basic).. 2 is again a cone but reversed (border-bottom).. #two created the bubble 一如既往地一样...(基本).. 2又是一个圆锥体,但倒转了(边框底部).. #two产生了气泡

 #holder { width: 500px; background-color: red; } #one { -webkit-border-radius: 60px; -moz-border-radius: 60px; border-radius: 60px; height: 200px; background-color: pink; } #two { margin: auto; position: relative; top: -80px; width: 0; height: 0; border-left: 70px solid transparent; border-right: 70px solid transparent; border-bottom: 100px solid pink; -moz-border-radius: 50%; -webkit-border-radius: 50%; border-radius: 50%; } 
 <div id="holder"> <div id="one">&nbsp;</div> <div id="two">&nbsp;</div> </div> 

You could use a couple of elements for this (I have used three, although I'm sure it's not the most efficient). 您可以为此使用几个元素(尽管我确定这不是最有效的,但我已经使用了三个)。 SVG may also be an option here. SVG在这里也可以选择。

CSS Solution: CSS解决方案:

 .wrap { height: 200px; width: 80%; margin-left: 10%; background: lightgray; position: relative; border-radius: 10px; } .a, .b { position: absolute; top: 100%; left: 50%; width: 50px; height: 25px; transform: translateX(-200%); overflow: hidden; } .b { transform: translateX(100%); } .a:before, .b:before { content: ""; position: absolute; top: 0; left: 0; height: 100%; width: 100%; border-radius: 0 100% 0 0; box-shadow: 0 0 0 50px lightgray; } .b:before { border-radius: 100% 0 0 0; } .wrap:before { content: ""; position: absolute; top: 100%; width: 100px; background: inherit; height:50px; left: 50%; transform: translateX(-50%); border-radius:0 0 50% 50%; } 
 <div class="wrap"> <span class="a"></span> <span class="b"></span> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM