circle()
åºçº¿
广æ³å¯ç¨
èª 2020å¹´1æ èµ·ï¼æ¤ç¹æ§å·²å¨ä¸»æµæµè§å¨ä¸å¾å°æ¯æï¼å¯å¨å¤§å¤æ°è®¾å¤åæµè§å¨çæ¬ä¸æ£å¸¸ä½¿ç¨ã
circle() CSS 彿°å®ä¹äºä¸ä¸ªåå½¢ï¼ä½¿ç¨åå¾åä½ç½®æ¥æè¿°ã宿¯ <basic-shape> æ°æ®ç±»åä¹ä¸ã
å°è¯ä¸ä¸
clip-path: circle(50px);
clip-path: circle(6rem at right center);
clip-path: circle(10% at 2rem 90%);
clip-path: circle(closest-side at 5rem 6rem);
clip-path: circle(farthest-side);
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element"></div>
</section>
#default-example {
background: #fe9;
}
#example-element {
background: linear-gradient(to bottom right, #f52, #05f);
width: 100%;
height: 100%;
}
è¯æ³
shape-outside: circle(50%);
clip-path: circle(6rem at 12rem 8rem);
å¼
<shape-radius>-
è¿å¯ä»¥æ¯ä¸ä¸ª
<length>å¼ï¼æè æ¯ä¸ä¸ª<percentage>å¼ï¼æè æ¯closest-sideåfarthest-sideå ³é®åå¼ãclosest-side-
使ç¨ä»å½¢ç¶ä¸å¿å°åç §çåçæè¿è¾¹ç¼çé¿åº¦ã对äºåå½¢æ¥è¯´ï¼è¿æ¯ä»»ä½ç»´åº¦ä¸æè¿çè¾¹ç¼ã
farthest-side-
使ç¨ä»å½¢ç¶ä¸å¿å°åç §çåçæè¿è¾¹ç¼çé¿åº¦ã对äºåå½¢æ¥è¯´ï¼è¿æ¯ä»»ä½ç»´åº¦ä¸æè¿çè¾¹ç¼ã
<position>-
ç§»å¨åçä¸å¿ãå¯ä»¥æ¯ä¸ä¸ª
<length>å¼ï¼æè æ¯ä¸ä¸ª<percentage>å¼ï¼æè æ¯ç±»ä¼¼leftçå¼ã妿çç¥äº<position>å¼ï¼åé»è®¤ä¸ºä¸å¿ã
å½¢å¼è¯æ³
<circle()> =
circle( <radial-size>? [ at <position> ]? )
<radial-size> =
<radial-extent> |
<length [0,â]> |
<length-percentage [0,â]>{2}
<position> =
<position-one> |
<position-two> |
<position-four>
<radial-extent> =
closest-corner |
closest-side |
farthest-corner |
farthest-side
<length-percentage> =
<length> |
<percentage>
<position-one> =
left |
center |
right |
top |
bottom |
x-start |
x-end |
y-start |
y-end |
block-start |
block-end |
inline-start |
inline-end |
<length-percentage>
<position-two> =
[ left | center | right | x-start | x-end ] && [ top | center | bottom | y-start | y-end ] |
[ left | center | right | x-start | x-end | <length-percentage> ] [ top | center | bottom | y-start | y-end | <length-percentage> ] |
[ block-start | center | block-end ] && [ inline-start | center | inline-end ] |
[ start | center | end ]{2}
<position-four> =
[ [ left | right | x-start | x-end ] <length-percentage> ] && [ [ top | bottom | y-start | y-end ] <length-percentage> ] |
[ [ block-start | block-end ] <length-percentage> ] && [ [ inline-start | inline-end ] <length-percentage> ] |
[ [ start | end ] <length-percentage> ]{2}
示ä¾
>åºæ¬åå½¢
å¨ä¸é¢ç示ä¾ä¸ï¼shape-outside 屿§çå¼ä¸º circle(50%)ï¼ç¨äºå¨æµ®å¨å
ç´ å¨å´ä½¿ææ¬ç¯ç»æåå½¢ã
<div class="box">
<img
alt="ä¸ä¸ªçæ°ç"
src="/proxy/mdn.github.io/shared-assets/images/examples/round-balloon.png" />
<p>
æ®è¯´ï¼1782 å¹´ 11
æçä¸ä¸ªå¤æï¼å¨æ³å½å°åå®è¯ºå
ï¼æä¸¤å
å¼åå¨å¬æ¥ççç«æï¼çççèéç°è²ççåæ²¿ç宽大ççå±è¢
è¢
åèµ·ãä»ä»¬çåå嫿¯èè¬Â·èå¥è²å°å约ç夫·èå¥è²å°ï¼è䏿¯é 纸工人ï¼ä»¥å¿æç¼å¯èç§°ï¼å¯¹ææç§å¦ç¥è¯åæ°åç°é½æçæµåçå
´è¶£ãå¨é£ä¸ªå¤æââä¸ä¸ªå¼å¾çºªå¿µç夿ââä¹åï¼æ°ä»¥äº¿è®¡ç人é½å¨æ³¨è§çèªå®¶çç«åèµ·ççåï¼å´æ²¡æä»ä¸å¾å°ä»»ä½ç¹å«çå¯åã
</p>
</div>
body {
font: 1.2em / 1.5 sans-serif;
}
img {
float: left;
shape-outside: circle(50%);
}
è§è
| è§è |
|---|
| CSS Shapes Module Level 1> # funcdef-basic-shape-circle> |
æµè§å¨å ¼å®¹æ§
åè§
- 使ç¨è¯¥æ°æ®ç±»åç屿§ï¼
clip-pathãshape-outside - åºæ¬å½¢ç¶æå