html怎么设置椭圆文本框,html – 避免CSS border-radius中的椭圆形状

形式上,border-radius属性的语法为每个角接受2个值:垂直半径和水平半径(用斜杠分隔).以下行将创建一个类似于上面第三个图像的椭圆边框半径.

border-radius: 5px/10px;

通常,我们只指定一个值.在这种情况下,该值被用作垂直和水平半径.以下行将创建一个类似于上面第二个图像的圆形边框半径.

border-radius: 10px;

使用百分比

Denotes the size of the circle radius or the semi-major and semi-minor axes of the ellipsis. It can be expressed in any unit allowed by the CSS data types. Negative values are invalid.

Denotes the size of the circle radius,or the semi-major and semi-minor axes of the ellipsis,using percentage values. Percentages for the horizontal axis refer to the width of the Box,percentages for the vertical axis refer to the height of the Box. Negative values are invalid.

当我们使用像素或ems这样的绝对长度单位时,使用单个值来创建圆形半径很好,但是当我们使用百分比时会变得更复杂.由于此属性的单值使用与使用相同值两次同义,因此以下两行是等效的;但是,这些不一定会产生圆形边界半径.

border-radius: 50%;

border-radius: 50%/50%;

这些线表示“创建一个椭圆或圆,其垂直半径等于元素高度的50%,其水平半径等于元素宽度的50%,并将其用作边界半径.”.如果元素宽200像素,高100像素,则会产生椭圆而不是圆形.

如果你想要一个圆形的边界半径,最简单的方法是使用绝对测量单位(如像素或ems或除百分比之外的任何东西),但有时候这不适合你的用例并且你想使用百分比.如果您知道包含元素的纵横比,您仍然可以!在下面的例子中,由于我的元素宽度是它的两倍,我将水平半径缩放了一半.

#rect {

width: 200px;

height: 100px;

background: #000;

border-radius: 25%/50%;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CSSborder-radius属性用于定义元素角的半径,从而实现元素的圆角样式。\[1\]可以通过指定一个或多个值来创建不同形的圆角。如果指定一个值,那么所有四个角的圆角都是一样的。如果指定两个值,第一个值用于左上角和右下角,第二个值用于右上角和左下角。如果指定三个值,第一个值用于左上角,第二个值用于右上角和左下角,第三个值用于右下角。如果指定四个值,分别对应左上角、右上角、右下角和左下角。\[1\] 此外,border-radius属性还可以创建椭圆角。如果两个弧线相交,轴向会分别缩小半径,直到圆弧不再相交,从而形成椭圆形。\[3\]可以通过设置width和height属性来控制元素的宽度和高度,然后使用border-radius属性来创建圆形或椭圆形。\[3\] 总结起来,通过CSSborder-radius属性,可以实现各种形的圆角效果,包括圆形、椭圆形和胶囊形。 #### 引用[.reference_title] - *1* [CSS 圆角属性 border-radius 用法](https://blog.csdn.net/CyberPlayer/article/details/123163476)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [CSS border-radius 能做什么?](https://blog.csdn.net/weixin_32518073/article/details/118301499)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [CSS-Learning | 使用border-radius创建圆形和胶囊形(长圆形)](https://blog.csdn.net/qq_35536883/article/details/89355150)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值