Javascript-форум (https://javascript.ru/forum/)
-   (X)HTML/CSS (https://javascript.ru/forum/xhtml-html-css/)
-   -   Убрать подчеркивание с псевдоэлемента (https://javascript.ru/forum/xhtml-html-css/85662-ubrat-podcherkivanie-s-psevdoehlementa.html)

voraa 12.12.2023 15:03

Убрать подчеркивание с псевдоэлемента
 
Такой макет
<head>
<style>
	.und {
		text-decoration: underline;
		text-decoration-thickness: 2px;
		text-underline-offset: 3px;
	}
	.num {
		text-decoration: none;
	}
	.num::after {
		content: "( " attr(data-num) " )";
		text-decoration: none;
    }
}

</style>
</head>
<body>
Lorem ipsum dolor sit amet, 
<span class="und">
	consectetur adipiscing
	<span class="num" data-num="1742"></span>
	elit
</span>
, sed do eiusmod tempor ...
</body>


Как бы убрать подчеркивание с псевдоэлемента (выводится как "( 1742 )" ) ?

text-decoration:none;
в .num и .num::after не помогают.

Aetae 12.12.2023 16:35

Никак, это underline родителя(что можно увидеть поменяв, например, цвет).
Либо менять вёрстку, либо костылить добавив элементу underline цвета фона, чтоб перекрывал родительский.

voraa 12.12.2023 16:58

Проблема решена. Теории не знаю, но помог display: inline-block;
Так работает
<head>
<style>
	.und {
		text-decoration: underline;
		text-decoration-thickness: 2px;
		text-underline-offset: 3px;
	}
	.num {
		text-decoration: none;
		display: inline-block;
	}
	.num::after {
		content: "( " attr(data-num) " )";
		text-decoration: none;
    }
}

</style>
</head>
<body>
Lorem ipsum dolor sit amet, 
<span class="und">
	consectetur adipiscing
	<span class="num" data-num="1742"></span>
	elit
</span>
, sed do eiusmod tempor ...
</body>


Смотрел в спеке, не очень хорошо понял, но там сказано, что подчеркивание как то по разному распространяется на строчные и блочные дочерние элементы.


Часовой пояс GMT +3, время: 21:13.