We have winner of 1st Tournamentwith css ...">

Superscript underlines text

I have an HTML code something like:

<div id="blah"> We have winner of 1<sup>st</sup> Tournament </div> 

with css

 #blah{ text-decoration:underline; } 

But that moves the underline from top to bottom, and it looks weird. Is there a way that I can fix using only css

+6
source share
7 answers

Simple try this

 #blah sup{ display:inline-block; border-bottom:1px solid #000; padding-bottom:2px;//as per your requirement } 
+8
source

use border-bottom instead of text-decoration (if you have only one line of text)

 #blah{ border-bottom:solid 1px black; display:inline-block; line-height:15px } 

Demo

+6
source

If you want to use underscore rather than the bottom border (these are two different things), then the only typographically acceptable solution seems to be to use superscript glyphs instead of sup markup or related CSS. You would do this with font-feature-settings .

The bad news is that among the fonts commonly installed on people's computers, only a few fonts, such as the so-called C-fonts (Calibri, Cambria, Candara, Consolas, Constantia, Corbel) and Palotino Linotype, contain such characters. There are also some limitations in browser support (for example, support for IE 9 and later). Example:

 <style> .sup { -webkit-font-feature-settings: "sups"; -moz-webkit-font-feature-settings: "sups"; font-feature-settings: "sups"; } </style> We have winner of 1<span class=sup>st</span> Tournament 

On the other hand, using this approach is safe in the sense that when the technique does not work, the rendering returns to the unoccupied โ€œ1stโ€ (under normal behavior).

0
source

The accepted answer did not work for me, because the border was sometimes compensated by underlining, depending on the browser scale and / or font size.

However, I found a solution on the Internet that did not have such an effect. All this thanks to the comment left by "ruthless" @ https://gist.github.com/unruthless/413930 , which credits Twitter user "chikuyonok". The user also provided a working example: http://jsfiddle.net/yyHNp/5/

Below is the example above, and works great for me.

 a { text-decoration: none; background: -moz-linear-gradient(left, red, red 100%); background: -ms-linear-gradient(left, red, red 100%); background: -o-linear-gradient(left, red, red 100%); background: -webkit-gradient(linear, 0 0, 100% 0, from(red), to(red)); background: -webkit-linear-gradient(left, red, red 100%); background: linear-gradient(left, red, red 100%); background-position: 0 100%; background-size: 10px 1px; background-repeat: repeat-x; } 
0
source

If you don't want to underline, but want the superscript or trademark to be part of the anchor tag. here is what i did. I wanted to emphasize only on hover.

code:

 a{text-decoration:none;} a:hover .supS{text-decoration:underline;display:inline-block;} 

Title Name & reg; Continuation
AT & T Uverseยฎ

demo link: http://jsfiddle.net/sunnysak/2ttx5/

hope this helps someone

-S

0
source

This can help, especially if you are trying to override the styles set by the framework or the useless default browser styles:

 #blah sup { position: static; display: inline; vertical-align: super; font-size: 75%; } 

Obviously also with

 #blah { text-decoration: underline; } 

like in the OP.

0
source

Just posted it elsewhere;

There is no simple solution to this problem (there always seems to be a situation that needs to be fixed). I needed only 2px or 1px underscore; 'u1' and 'u2'. Although I saved "u" as simply {text-decoration: underline;} (I like to keep it short and sweet)

(works with a wrapper).

HTML:

 <span class="u2"> Registered<sup>&reg;</sup> </span> 

CSS

 .u2{ border-bottom:2px solid #666666;display:inline; } sup{ font-size: 40%; display: inline; vertical-align: top; } 

https://jsfiddle.net/sLtkx2qe/

0
source

Source: https://habr.com/ru/post/946176/


All Articles