简体   繁体   English

Angular Primeng carousel - 自定义 Prev 和 Next 按钮

[英]Angular Primeng carousel - Custom Prev and Next button

I have explained everything in the attached image.我已经解释了附图中的所有内容。 and all CSS code are in the stackblitz.并且所有 CSS 代码都在 stackblitz 中。

Basically I want a customized Next and Prev button.基本上我想要一个自定义的 Next 和 Prev 按钮。 I want the border of the Next and Prev button to be same as the inside boxes.我希望 Next 和 Prev 按钮的边框与内框相同。 and with rounded corner.并带有圆角。 (that means to show that there is a Prev or Next box still available so use can click on Next/Prev (这意味着显示有一个 Prev 或 Next 框仍然可用,因此使用可以单击 Next/Prev

The problem I am getting now is when I click on the Next/Prev, the border is getting bold and blue.我现在遇到的问题是当我单击 Next/Prev 时,边框变得粗体和蓝色。 I believe it is coming from the default browser(not sure though)我相信它来自默认浏览器(虽然不确定)

https://stackblitz.com/edit/primeng-carousel-demo-i1lnft 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;
}

在此处输入图像描述

There's a box-shadow that is added when the button is focused.当按钮获得焦点时,会添加一个框阴影。

You can remove it with this style:您可以使用以下样式将其删除:

::ng-deep .p-carousel .p-carousel-content .p-carousel-prev:focus {
  box-shadow: none;
}

Also, I think this is what you mentioned in the image, but the previous button have border width set to thick, it should be changed to thin to match the next button:另外,我认为这是您在图像中提到的,但是上一个按钮的边框宽度设置为粗,应将其更改为细以匹配下一个按钮:

::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;
}

Here's the updated demo: https://stackblitz.com/edit/primeng-carousel-demo-dbzinn这是更新的演示: https://stackblitz.com/edit/primeng-carousel-demo-dbzinn

do you want to keep the blue border?你想保留蓝色边框吗? because this is enough to edit your buttons:因为这足以编辑您的按钮:

.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; */
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM