You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整Vanilla Framework高亮卡片的顶部色条、圆角与阴影?

调整Vanilla Framework高亮卡片的样式

针对你提到的三个样式需求,可通过自定义CSS覆盖Vanilla Framework的默认样式来实现,具体方案如下:

实现代码

<link rel="stylesheet" href="https://assets.ubuntu.com/v1/vanilla-framework-version-4.2.0.min.css" />
<style>
/* 1. 将高亮条移到卡片顶部,移除默认底部高亮 */
.p-card--highlighted {
  border-top: 4px solid #007aa6; /* 采用Vanilla默认高亮色,可按需修改 */
  border-bottom: none;
  /* 2. 设置卡片圆角 */
  border-radius: 8px; /* 圆角大小可自行调整 */
  overflow: hidden; /* 确保内部元素不超出圆角范围 */
  /* 3. 加深卡片阴影 */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); /* 比默认阴影更醒目,参数可微调 */
}

/* 确保顶部图片适配卡片圆角 */
.p-card__image {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}
</style>

<div class="col-4">
   <div class="p-card--highlighted">
      <img class="p-card__image" src="https://assets.ubuntu.com/v1/0f33d832-The-State-of-Robotics.jpg">
      <div class="p-card__inner">
         <h3>The State of Robotics - August 2021</h3>
         <p>From robots learning to encourage social participation to detect serious environmental problems, it was a learning month.</p>
      </div>
      <hr class="u-no-margin--bottom">
      <div class="p-card__inner">
         by <a href="#">Bartek Szopka</a> on 21st August 2021
      </div>
   </div>
</div>

样式说明

  • 顶部高亮条:给.p-card--highlighted添加顶部边框,同时移除默认的底部高亮边框,颜色可根据设计需求替换。
  • 卡片圆角:通过border-radius设置圆角,配合overflow: hidden保证内部元素不突破圆角,单独给顶部图片设置圆角避免边缘错位。
  • 加深阴影:调整box-shadow的模糊半径和透明度,增强阴影的视觉存在感,参数可根据实际视觉需求微调。

内容的提问来源于stack exchange,提问作者Saugat Awale

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 03:51:03