[英]Styling an element within another styled as a pseudo element first-line
I am using a pseudo-element to style the first line of a paragraph (class="first-para") in my document:我正在使用伪元素来设置文档中段落的第一行 (class="first-para") 的样式:
.first-para::first-line {
font-weight: bold;
font-size: calc(var(--fontSize) * 1.25);
}
Is it possible to have a link element within that first line to use the pseudo style also, ie bold and larger font-size, in addition to its link styling?除了链接样式之外,是否可以在第一行中有一个链接元素也使用伪样式,即粗体和更大的字体大小? I can't assign the same styling directly to the link because on smaller width screens the link would not be in the first line.我不能将相同的样式直接分配给链接,因为在较小宽度的屏幕上,链接不会在第一行。 Here's the current attempt: article这是当前的尝试:文章
There is this rule in your CSS, which also affects the a
link element in your first line:您的 CSS 中有此规则,它也会影响第一行中a
链接元素:
p, li, b, i, a, mark {
font-size: var(--fontSize);
line-height: var(--lineHeight);
letter-spacing: var(--letterSpacing);
font-feature-settings: normal;
}
So to avoid that affecting the a
element in your .first-para
paragraph, create/add a rule for .first-para a
which resets those settings by using inherit
for all values:因此,为避免影响.first-para
段落中的a
元素,请为.first-para a
创建/添加一个规则,该规则通过对所有值使用inherit
来重置这些设置:
.first-para a {
font-size: inherit;
line-height: inherit;
letter-spacing: inherit;
font-feature-settings: inherit;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.