如何解决Angular Primeeng 轮播 - 自定义上一个和下一个按钮
我已在附图中解释了所有内容。并且所有 CSS 代码都在 stackblitz 中。
基本上我想要一个自定义的 Next 和 Prev 按钮。我希望 Next 和 Prev 按钮的边框与内部框相同。并带有圆角。 (这意味着显示还有一个 Prev 或 Next 框仍然可用,所以使用可以点击 Next/Prev
我现在遇到的问题是当我点击 Next/Prev 时,边框变得粗体和蓝色。我相信它来自默认浏览器(虽然不确定)
https://stackblitz.com/edit/primeng-carousel-demo-i1lnft
.p-carousel-prev-icon,.pi {
display: none !important;
}
.pi {
display: none !important;
}
.pi-chevron-left:before {
content: '' !important;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-next::after {
width: 0.513rem;
height: 1.25rem;
font-size: 0.875rem;
font-family: Roboto;
transform: scale(2,4);
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-prev {
width: 2.513rem;
height: 5.68rem;
border-radius: 25%;
border-right-color: #99bbff;
border-right-style: solid;
border-right-width: thick;
border-top-color: #99bbff;
border-top-style: solid;
border-top-width: thick;
border-bottom-color: #99bbff;
border-bottom-style: solid;
border-bottom-width: thick;
margin: 0 0 0 -5px;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-next {
width: 2.513rem;
height: 5.68rem;
border-radius: 25%;
border-left-color: #99bbff;
border-top-color: #99bbff;
border-bottom-color: #99bbff;
border-left-style: solid;
border-top-style: solid;
border-bottom-style: solid;
border-left-width: thin;
border-top-width: thin;
border-bottom-width: thin;
margin: 0 -5px 0 0;
outline: none !important;
}
.p-carousel-next:focus {
border-left-style: solid !important;
border-top-style: solid !important;
border-bottom-style: solid !important;
border-left-width: thin !important;
border-top-width: thin !important;
border-bottom-width: thin !important;
outline: none !important;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-next:focus {
border-left-style: solid !important;
border-top-style: solid !important;
border-bottom-style: solid !important;
border-left-width: thin !important;
border-top-width: thin !important;
border-bottom-width: thin !important;
outline: none !important;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-next:hover {
border-left-style: solid !important;
border-top-style: solid !important;
border-bottom-style: solid !important;
border-left-width: thin !important;
border-top-width: thin !important;
border-bottom-width: thin !important;
outline: none !important;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-next:enabled {
border-left-style: solid !important;
border-top-style: solid !important;
border-bottom-style: solid !important;
border-left-width: thin !important;
border-top-width: thin !important;
border-bottom-width: thin !important;
outline: none !important;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-next:enabled:hover {
border-left-style: solid !important;
border-top-style: solid !important;
border-bottom-style: solid !important;
border-left-width: thin !important;
border-top-width: thin !important;
border-bottom-width: thin !important;
outline: none !important;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-next:active {
border-left-style: solid !important;
border-top-style: solid !important;
border-bottom-style: solid !important;
border-left-width: thin !important;
border-top-width: thin !important;
border-bottom-width: thin !important;
outline: none !important;
}
::ng-deep .p-carousel .p-carousel-content .p-carousel-prev::after {
width: 0.513rem;
height: 1.25rem;
font-size: 0.875rem;
font-family: Roboto;
transform: scale(2,4);
}
::ng-deep .p-disabled {
/* visibility: hidden !important; */
border-left-color: white !important;
border-right-color: white !important;
border-top-color: white !important;
border-bottom-color: white !important;
}
解决方法
当按钮获得焦点时会添加一个框阴影。
您可以使用此样式将其删除:
::ng-deep .p-carousel .p-carousel-content .p-carousel-prev:focus {
box-shadow: none;
}
另外,我想这就是你在图片中提到的,但是上一个按钮的边框宽度设置为粗,应该更改为细以匹配下一个按钮:
::ng-deep .p-carousel .p-carousel-content .p-carousel-prev {
width: 2.513rem;
height: 5.68rem;
border-radius: 25%;
border-right-color: #99bbff;
border-right-style: solid;
border-right-width: thin;
border-top-color: #99bbff;
border-top-style: solid;
border-top-width: thin;
border-bottom-color: #99bbff;
border-bottom-style: solid;
border-bottom-width: thin;
margin: 0 0 0 -5px;
}
这是更新后的演示:https://stackblitz.com/edit/primeng-carousel-demo-dbzinn
,你想保留蓝色边框吗?因为这足以编辑您的按钮:
.p-carousel-next,.p-carousel-prev {
box-shadow: none !important;
border-width: 1px !important;
/* if you wish to remove the border or change its color */
/* border: transparent !important; */
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。