Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font outline using only CSS

I'm working on adding a black font outline to white text using CSS. The goal is the image below. So far I've been able to come up with below. Is there any other best practice to closer match the thin outline shown in the image below? Thanks!

.introText {
font-family: 'Nunito', sans-serif;
-moz-text-fill-color: white;
-webkit-text-fill-color: white;
-moz-text-stroke-color: black;
-webkit-text-stroke-color: black;
-moz-text-stroke-width: 2px;  
-webkit-text-stroke-width: 2px;
font-size: 50px;
margin-top: 20vh;
}
}
<h1 class='introText text-center'>We've got your perfect spot.</h1>

enter image description here

like image 416
AndrewLeonardi Avatar asked Dec 11 '22 02:12

AndrewLeonardi


1 Answers

One way to do that is to use text-shadow and overlap multiple shadows:

.introText {
   text-shadow: 0 0 1px black, 0 0 1px black, 0 0 1px black, 0 0 1px black;
}

4 times in this case.

Example:

.introText {
        font-family: "Nunito", sans-serif;
        text-shadow: 0 0 1px black, 0 0 1px black, 0 0 1px black, 0 0 1px black; 
        color: white;
        font-size: 50px;
        margin-top: 20vh;
      }
    <h1 class="introText text-center">We've got your perfect spot.</h1>

It creates a very similar effect and you can make it stronger or weaker depending on how many repetitions you use.

like image 149
Azametzin Avatar answered Dec 14 '22 22:12

Azametzin