如何将箭头重叠到下面的div上?(How to overlap an arrow onto the div below?)

编程入门 行业动态 更新时间:2024-10-09 22:20:05
如何将箭头重叠到下面的div上?(How to overlap an arrow onto the div below?)

我试图让箭头重叠到它下方的div上(灰色箭头重叠在http://tinyletter.com上的红色上的方式)。

这是我目前使用的代码:

#box_1 { height: 550px; width: 100%; font-size: 4.5em; font-weight: 600; float: center; text-align: center; background-color: #ededed; padding: 55px 0 0 0; } .arrow-down { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 50px solid #ededed; margin-left:auto; margin-right:auto; } #box_2 { height: 600px; width: 100%; font-size: 7em; float: center; text-align: center; background-color: #ed2227; }

I am trying to make an arrow overlap onto the div below it (the way the gray arrow overlaps onto the red on http://tinyletter.com).

Here is the code I am currently using:

#box_1 { height: 550px; width: 100%; font-size: 4.5em; font-weight: 600; float: center; text-align: center; background-color: #ededed; padding: 55px 0 0 0; } .arrow-down { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 50px solid #ededed; margin-left:auto; margin-right:auto; } #box_2 { height: 600px; width: 100%; font-size: 7em; float: center; text-align: center; background-color: #ed2227; }

最满意答案

如果你能够依赖于使用::after (或::before )伪元素,那么只需使用border s就可以了:

#top { position: relative; background-color: #ccc; } #top::after { position: absolute; content: ''; top: 100%; left: 50%; margin: 0 0 0 -1em; border: 1em solid transparent; border-top: 1em solid #ccc; }

JS小提琴演示 。

If you're able to rely upon use of the ::after (or ::before) pseudo-elements, then this is relatively easy simply using borders:

#top { position: relative; background-color: #ccc; } #top::after { position: absolute; content: ''; top: 100%; left: 50%; margin: 0 0 0 -1em; border: 1em solid transparent; border-top: 1em solid #ccc; }

JS Fiddle demo.

更多推荐

本文发布于:2023-07-06 07:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047308.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:箭头   如何将   div   overlap   arrow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!