如何制作对角线div

编程入门 行业动态 更新时间:2024-10-28 18:25:25
本文介绍了如何制作对角线div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的 div 标签,我想在红色区域写你好。我该怎么写呢?请帮忙!

This is my div tag where I want to write hello on red area. How do I write it into that? Please help!

.arrow-right { height: 100px; margin-left: 10px; background-color: blue; border-top: 170px solid red; border-right: 170px solid orange; width: 200px; padding-top: -190px; }

<div class="arrow-right">Hello</div>

推荐答案

我使用了定位和伪元素来实现这个目标:

I've used positioning and a pseudo element to achieve this:

.arrow-right { height: 100px; margin-left: 10px; background-color: blue; border-top: 170px solid red; border-right: 170px solid orange; width: 200px; position:relative; } .arrow-right:before{ content:"hello"; position:absolute; top:-170px; font-size:50px }

<div class="arrow-right"></div>

所以,如果你只想要'红色'部分,你最终会得到类似的东西:

So, if you only wanted the 'red' part, you would end up with something similar to this:

.arrow-right { height: 1px; background-color: transparent; border-top: 170px solid red; border-right: 170px solid transparent; width: 200px; position:relative; } .arrow-right:before{ content:"hello"; position:absolute; top:-170px; font-size:50px }

<div class="arrow-right"></div>

更多推荐

如何制作对角线div

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

发布评论

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

>www.elefans.com

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