font-size设置大小小于12px时,需要使用transform: scale(numX, numY)属性详解

本文介绍了当浏览器限制字体大小时如何使用CSS的transform:scale属性来调整元素大小的方法及注意事项,包括默认居中缩小的问题解决及应用技巧。

1. 为啥要使用transform: scale(numX, numY)属性

由于浏览器为了提升用户的浏览体验,设置字体最小为12px,如果继续缩小字体,样式就不会生效,此时就需要使用transform: scale(numX, numY)属性

2.transform: scale(numX, numY)注意事项

  1. transform: scale(numX, numY)属性表示缩小盒子的大小,并不是缩小字体,所有只对块级盒子其效果
  2. 由于transform: scale(numX, numY)默认居中缩小,所以可以添加transform-origin: 0 0属性,使盒子左上缩小
  3. numX, numY表示缩小的倍数,如0.8表示缩小0.8倍
  4. transform: scale(numX, numY)缩小后盒子的所占空间并没有缩小,所有如果想要让后面的盒子紧跟着,可以设置margin-right: -num.
void UTFCharacterMovementComponent::LedgeCollectionFunct(const FVector& Start, const FVector& Normal, const float NumX,const float NumY) { ImpactNormal = Normal; TArray<int32> Triangles; TArray<FVector2D> UVs; static int32 CollectCnt = 1; if (bStartToCollection && GirdLocation.Num() > 0) { // 计算当前批次的索引范围 int32 BatchSize = GirdLocation.Num() / 4; // 假设分4批处理 int32 StartIndex = (CollectCnt - 1) * BatchSize; int32 EndIndex = FMath::Min(CollectCnt * BatchSize, GirdLocation.Num()); for (int32 Index = StartIndex; Index < EndIndex; Index++) { FVector CurrentVertex = GirdLocation[Index]; // 根据GirdLocation绘制矩阵射线检测 { FRotator InitialRot = FRotationMatrix::MakeFromX(ImpactNormal).Rotator(); FVector RightVector = InitialRot.RotateVector(FVector::RightVector); FVector UpVector = InitialRot.RotateVector(FVector::UpVector); FVector ForwardVector = InitialRot.RotateVector(FVector::ForwardVector); FRotator FinalRotation = FRotationMatrix::MakeFromXY(RightVector, UpVector).Rotator(); FVector Scale(1.0f, 1.0f, 1.0f); FTransform Transform = FTransform(FinalRotation,Start, FVector(1.0f, 1.0f, 1.0f)); FTransform InverseTransform = Transform.Inverse(); FVector LocalTransformVector = InverseTransform.InverseTransformPosition(CurrentVertex); FVector StartLoc = LocalTransformVector + Normal * 100; FVector EndLoc = LocalTransformVector - Normal * 100; FHitResult HitResult; bool bHit = UKismetSystemLibrary::SphereTraceSingle( GetWorld(), StartLoc, EndLoc, 10.f, UEngineTypes::ConvertToTraceType(ECC_Visibility), false, TArray<AActor* >(), EDrawDebugTrace::None, HitResult, true ); //角度检测 FVector ImpactLoc = (HitResult.ImpactPoint - RefLocation).GetSafeNormal(); float DotProduct = FVector::DotProduct(RefNormal,ImpactLoc); float AbsAngleDeg = FMath::Abs(FMath::Acos(DotProduct)); if (AbsAngleDeg < 45.0f) { if (FVector::Distance(HitResult.ImpactPoint ,StartLoc)>1.0f) { MatrixTraceLocation = HitResult.ImpactPoint; MatrixTraceNormal = FVector(HitResult.ImpactNormal.X, HitResult.ImpactNormal.Y, 0); } } } /*UE_LOG(LogTemp, Log, TEXT("处理顶点 %d: (%f, %f, %f)"), Index, CurrentVertex.X, CurrentVertex.Y, CurrentVertex.Z);*/ } // 准备下一批次 CollectCnt++; if (CollectCnt > 4) // 如果所有批次处理完毕 { bStartToCollection = false; // 重置状态,下次重新生成网格 CollectCnt = 1; } } else { UKismetProceduralMeshLibrary::CreateGridMeshWelded( NumX, NumY, Triangles, GirdLocation, UVs, 16.0f ); bStartToCollection = true; CollectCnt = 1; } } 代码片段是这个
最新发布
11-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值