我如何修改< p>的字体尺寸在离子6中的离子卡内部标记6

发布于 2025-01-23 19:40:05 字数 880 浏览 5 评论 0 原文

像这个问题一样,我正在使用VUE 3和Ionic 6开发一个项目。

我想更改< p> < ion-card-content>中的字体大小。

我的页面:

<ion-card>
   <ion-card-header>
     <ion-card-title>Title</ion-card-title>
     <ion-card-subtitle>Sub Title</ion-card-subtitle>
   </ion-card-header>
   <ion-card-content v-html="data.content">
   </ion-card-content>
</ion-card>

data.content 是从服务器请求的。它的结构就像以下内容:

<p>This is my page!</p>
<p>Welcome to my home.</p>

我看到它在Chrome Devtools中进行了样式。

.card-content-md p {
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.5;
}

但是我不知道如何修改它,我想修改字体大小:16px。

谁能帮忙?谢谢。

Like the question, I am developing a project using vue 3 and ionic 6.

I want to change the font-size of the <p> tag in <ion-card-content>.

my page:

<ion-card>
   <ion-card-header>
     <ion-card-title>Title</ion-card-title>
     <ion-card-subtitle>Sub Title</ion-card-subtitle>
   </ion-card-header>
   <ion-card-content v-html="data.content">
   </ion-card-content>
</ion-card>

data.content is requested from the server. Its structure is like this:

<p>This is my page!</p>
<p>Welcome to my home.</p>

I see it styled in chrome devtools.

.card-content-md p {
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.5;
}

But I don't know how to modify it, I want to modify font-size: 16px.

Can anyone help? Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

糖粟与秋泊 2025-01-30 19:40:05

解决此问题的唯一方法是删除带有与离子卡符号相同特征的DIV标签的离子卡符号标签。这是一种更好的解决方案,因为现在您可以自定义您的离子卡包含。

我尝试相同的方式,对我有用。请记住,离子文档中的离子卡 - 包含没有CSS信息:

The only way to fix this problem is to remove the ion-card-content tag and replace with a div tag with the same characteristics as the ion-card-content. This is a way better solution because now you can customize your ion-card-content.

I try the same way and it works for me. Remember that ion-card-content has no CSS information in the ionic documentation: https://ionicframework.com/docs/api/card-content#css-custom-properties

心在旅行 2025-01-30 19:40:05

在.css中,您想更改离子卡标签的字体大小或在全球CSS中以各处更改它。

ion-card-title{
    font-size: 20px !important;
}

In the .css where you want to change the Font-Size of a ion-card-title or in the global css to change it everywhere.

ion-card-title{
    font-size: 20px !important;
}
过期情话 2025-01-30 19:40:05

以下对我有用:

ion-card-content[class*="card-content-"] > p{
  font-size: 10px !important;
}

或者,如果您想针对特定类别:

ion-card-content[class*="card-content-"].card-text > p{
  font-size: 10px !important;
}

当然,这需要进行全局。SCSS。
我希望这对某人有用。

The below worked for me:

ion-card-content[class*="card-content-"] > p{
  font-size: 10px !important;
}

or if you want to target an specific class:

ion-card-content[class*="card-content-"].card-text > p{
  font-size: 10px !important;
}

Of course, this needs to go on your global.scss.
I hope this can be useful to someone.

向日葵 2025-01-30 19:40:05

检查: https://ionicframe.com/docs/docs/docs/theming/theming/css-variobles

尝试 JavaScript:

const el = document.querySelector('.card-content-md p');
el.style.setProperty('--font-size', '16px');

Check: https://ionicframework.com/docs/theming/css-variables

Try javascript:

const el = document.querySelector('.card-content-md p');
el.style.setProperty('--font-size', '16px');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文