胖鸭 2011-08-16 03:54
浏览 520
已采纳

三角形是如何工作的?

There're plenty of different CSS shapes over at CSS Tricks - Shapes of CSS and I'm particularly puzzled with a triangle:

CSS Triangle

#triangle-up {
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 100px solid red;
}
<div id="triangle-up"></div>

How and why does it work?

</div>

转载于:https://stackoverflow.com/questions/7073484/how-do-css-triangles-work

  • 写回答

17条回答 默认 最新

  • 撒拉嘿哟木头 2011-08-16 04:11
    关注

    CSS Triangles: A Tragedy in Five Acts

    As alex said, borders of equal width butt up against each other at 45 degree angles:

    borders meet at 45 degree angles, content in middle

    When you have no top border, it looks like this:

    no top border

    Then you give it a width of 0...

    no width

    ...and a height of 0...

    no height either

    ...and finally, you make the two side borders transparent:

    transparent side borders

    That results in a triangle.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(16条)

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动