


How to use css to draw triangles directly and in dialogue form (code attached)
The content of this article is about how to use css to directly draw triangles and triangles in dialogue form (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. helped.
In product display, triangles often appear, such as the triangle label in the upper left corner, or the triangle in the form of a dialogue, with a shadow effect, etc. I will record it here
1 , add triangles directly
<div> <div> <div></div> <div>想你呦</div> </div> </div> <style> body { background: #e5e5e5; } .triangleContainer { margin: 50px auto; width: 500px; height: 400px; background: #fff; } .triangleContent { position: relative; } .triangle { position: absolute; right: -70px; top: -70px; transform: rotate(45deg); /* 比较长的写法 */ /*border-top: 70px solid transparent;*/ /*border-bottom: 70px solid red;*/ /*border-left: 70px solid transparent;*/ /*border-right: 70px solid transparent;*/ /* 简单写法 */ border: 70px solid transparent; border-bottom-color: red; } .title { position: absolute; right: 8px; top: 17px; transform: rotate(45deg); font-size: 19px; color: #fff; } </style>
2, use pseudo-class to add triangles (with shadow effect)
Add two pseudo-classes: one pseudo-class implements triangle, Another use of positioning to achieve shadow effects
<view> <text>邀请越多的好友,中奖几率越高哦!</text> <text>我知道了</text> </view> .promptInfo{ position: absolute; left: 5%; top: -28rpx; margin: 0 auto; padding: 20rpx 0; box-sizing: border-box; width: 88%; border-radius: 10rpx; z-index: 999; background: #fff; box-shadow: 3rpx 3rpx 3rpx rgba(0,0,0,.2); border: 0; font-size: 30rpx; } /* 添加与阴影颜色相同来形成三角形的阴影效果 */ .promptInfo::before{ position: absolute; bottom: -21rpx; right: 110rpx; z-index: 999; border-top: 20rpx solid rgba(0,0,0,.2); border-left: 20rpx solid transparent; border-right: 20rpx solid transparent; content: "" } .promptInfo::after{ position: absolute; bottom: -17rpx; right: 110rpx; z-index: 999; border-top: 20rpx solid #fff; border-left: 20rpx solid transparent; border-right: 20rpx solid transparent; content: "" } .promptInfo .inviteMessage{ padding-left: 30rpx; } .promptInfo .clickMessage { display: inline-block; margin-left: 15rpx; padding: 10rpx 20rpx; color: #fff; background: red; border-radius: 30rpx; }
Related recommendations:
css to create triangles, drop-down box triangles_html/css_WEB-ITnose
Use div css to implement triangles, with words inside the triangle_html/css_WEB-ITnose
css to implement rounded triangles method
The above is the detailed content of How to use css to draw triangles directly and in dialogue form (code attached). For more information, please follow other related articles on the PHP Chinese website!

Here's a container with some child elements:

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about it:


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.