Bootstrap 如何删除css/app.css中的规则与我的css文件?

8aqjt8rx  于 2023-08-01  发布在  Bootstrap
关注(0)|答案(3)|浏览(114)

在laravel 8/ coreui 3.4应用页面新闻

<x-layouts.news>
    <x-slot name="title">{{ trans('News') }}</x-slot>

    ...
    <div class="news-content">{!! \Purifier::clean($news->content_shortly) !!}</div>
    ...

</x-layouts.news>

字符串
基于常见的应用程序布局/css与resources/views/layouts/news.blade.php模板,其中有2个css文件包括:

...
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<link rel="stylesheet" href="{{ mix('css/news.css') }}">
...


问题是,当新闻的content_shortly

<i> and <strong>


标签,它们不会呈现在表单上,并在浏览器中检查页面,我看到这些样式是从父html * {:https://prnt.sc/tiYMT3I1NFEo
如果有一种方法可以删除这些html * {规则在我的页面上,但不编辑css/app.css,但只有news.css,因为这些规则在应用程序的其他页面上使用?

使用unset尝试修复:

当我遇到这个问题时,用户填写

<i>


和/或

<strong>


ckeditor 5中的标签
我在我的scss顶部添加

strong {
    font-weight: unset;
}

i {
    font-weight: unset;
}


但无论如何都不起作用,在浏览器中我看到:https://prnt.sc/tTObhLlAvgUR
我试着添加风格:

html * {
    font-weight: unset !important;
    text-decoration: unset !important;
    font-style:  unset !important;
}

* {
    font-weight: unset !important;
    text-decoration: unset !important;
    font-style:  unset !important;
}


但这也没有帮助-标签根本没有呈现...

swvgeqrz

swvgeqrz1#

如果我理解正确的话,您希望在<strong>中保留螺栓,在<i>中保留斜体,即这些元素的初始值。我想你可以使用revert值:

html * {
  font-weight: 400;
  font-style: normal;
}

/* instead of html, you can specify a content wrapper 👇 */
html i {
  font-style: revert;
}

html strong {
  font-weight: revert;
}

个字符

5vf7fwbs

5vf7fwbs2#

您可以在CSS文件中添加!important标志。

.news-content,
.news-content > p {
    font-size: 14px !important;
    font-weight: 400 !important;
    line-height: 24px !important;
}

字符串
它会覆盖你的父CSS。

z31licg0

z31licg03#

对要删除的每个规则使用unset:

* {
    font-weight: unset;
  }

字符串
https://developer.mozilla.org/en-US/docs/Web/CSS/unset
unset CSS关键字将属性重置为它的继承值(如果属性自然地从其父属性继承),否则重置为它的初始值。换句话说,当属性是继承属性时,它的行为与第一种情况下的inherit关键字相似;当属性是非继承属性时,它的行为与第二种情况下的initial关键字相似。

相关问题