html边框变箭头,CSS3 各个方向的信息框箭头

本文介绍了一种使用CSS实现特殊效果的方法,包括如何通过设置box-sizing属性来优化布局,以及如何利用伪元素和转换属性创建倾斜的段落和带有三角形装饰的盒子。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CSS

语言:

CSSSCSS

确定

/* Fonts */

@import "https://fonts.googleapis.com/css?family=Pacifico";

/* Variables for box and CSS triangles */

/* End Variables */

* {

box-sizing: border-box;

}

html,

body {

min-height: 100%;

}

body {

font-size: 16px;

}

header {

font-family: 'Pacifico', cursive, Sans-Serif;

font-size: 48px;

color: #4d4d4d;

text-align: center;

margin: 45px 0 15px;

}

header span {

display: block;

}

header small {

font-size: 50%;

color: #999999;

}

.wrapper {

width: 620px;

height: auto;

display: block;

margin-left: auto;

margin-right: auto;

}

/* box styles */

.box {

width: 260px;

height: 173.33333px;

float: left;

margin: 25px;

background-color: #d66c5c;

padding: 15px;

border-radius: 3.25px;

position: relative;

}

.box .triangle {

width: 0;

height: 0;

position: absolute;

z-index: 1;

border-width: 13px;

border-style: solid;

border-color: transparent;

}

.box .triangle.top {

border-bottom-color: #d66c5c;

top: -26px;

left: 50%;

-webkit-transform: translateX(-50%);

transform: translateX(-50%);

}

.box .triangle.right {

border-left-color: #d66c5c;

right: -26px;

top: 50%;

-webkit-transform: translateY(-50%);

transform: translateY(-50%);

}

.box .triangle.bottom {

border-top-color: #d66c5c;

bottom: -26px;

left: 50%;

-webkit-transform: translateX(-50%);

transform: translateX(-50%);

}

.box .triangle.left {

border-right-color: #d66c5c;

left: -26px;

top: 50%;

-webkit-transform: translateY(-50%);

transform: translateY(-50%);

}

/* End of box */

/* CSS for p tags */

p {

position: absolute;

top: 0;

left: 0;

width: 260px;

height: 173.33333px;

text-align: center;

line-height: 173.33333px;

color: white;

font-family: 'Pacifico', cursive, Sans-Serif;

font-size: 36px;

-webkit-transform: rotate(-5deg);

transform: rotate(-5deg);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值