Jump to content

How do I use Text Stroke, so the text can "disappear" off the screen?


simona6

Recommended Posts

.custom-stroke-text-effect-1 {
    -webkit-text-fill-color: #FFF;
    -webkit-text-stroke-width: 1px;
    -webkit-text-stroke-color: #2a2a2a;
    white-space: nowrap;
    font-size: 7rem;
    opacity: 0.1;
    font-family: "Geomanist";
    margin-top: 41px;
}

@media only screen and (max-width: 950px) {
 .custom-stroke-text-effect-1 {
    font-size: 4rem;
}   
}

I am trying to create an effect so the outline text is above and slightly behind the text below it (layered).

Trouble is, on some screens the text goes off the page, causing the sidebars.

I tried overflow:hidden, but that oddly, crops the top and bottom of the text... no idea why.

I could do it with a background image, but prefer it as text if poss.  So it's easier to tweak.

Any ideas?

Bit like the attached, but so the outline text can be bigger.

Screenshot 2023-08-13 at 11.20.09.png

Link to comment
Share on other sites

Does this SVG version fit the bill?

    <div>
        <svg width='100%' viewBox='0 0 1400 200'>
            <defs>
                <style type='text/css'>
                    .text1 {
                        font-family: arial, sans-serif;
                        font-size: 140pt;
                        font-weight: 600;
                        stroke: #DDD;
                        fill: #FFF;
                    }
                    .text2 {
                        font-family: arial, sans-serif;
                        font-size: 70pt;
                        font-weight: 600;
                        fill: #4e1d8f;
                    }
                    .period {
                        fill: #96bd0b;
                    }
                </style>
            </defs>
            <text class='text1' x='50' y='150'>
               UK SUPPORT
            </text>
            <text class='text2' x='50' y='180'>
               Local & UK Website Design
            </text>
            <circle class='period' cx='1280' cy='170' r='10' />
        </svg>
    </div>

image.png.c261f3aad742457f3766187ea9f10a19.png

Link to comment
Share on other sites

Sorry I'm puzzled.

Does this SVG method take on the font used on the site?

I've read you can use a vw font size, but I don't really understand it. I assumed you could set a font to be say, 90% width of the viewpoint of the screen, or the container.  So it will stretch to fit.  So rather than one version for that media size,and another for multiple - you can just use a VW version that "fits all".

 

but it doesn't work.

Link to comment
Share on other sites

8 minutes ago, simona6 said:

Does this SVG method take on the font used on the site?

At present, the font to be used is defined in the two text styles within the SVG. If you remove those two font-family attributes it will default to the font used by the parent (page body). If a different font is used you will have to adjust the font sizes and text positions, or adjust the "canvas"size (viewBox)

Currently <svg width='100%' ... > fits the image to the width of the container. The whole image will scale proportionately as the container size changes so it alway fills the width.

Link to comment
Share on other sites

<div>
        <svg width='100%' viewBox='0 0 1400 200'>
            <defs>
                <style type='text/css'>
.text1 {
padding-top: 50px;
    font-family: Geomanist-Bold;
    font-size: 193pt;
    font-weight: 600;
    stroke: #d3cdcd;
    stroke-width: 2px;
    fill: transparent;
}
                </style>
            </defs>
            <text class='text1' x='50' y='150'>
               WordPress
            </text>
        </svg>
    </div>

This Crops top and bottom for some reason.

I also assuemd the Font size would be a percentage, so that's a bit confusing to me.  I assume SEO does pick this up, as it is "text"?  (tho the words in this case are not vital).

Just assumed you could haev text that is a percentage of it's containing DIV.

Link to comment
Share on other sites

<div>
        <svg width='100%' viewBox='0 0 1400 200'>
            <defs>
                <style type='text/css'>
.text1 {
padding-top: 50px;
    font-family: Geomanist-Bold;
    font-size: 193pt;
    font-weight: 600;
    stroke: #d3cdcd;
    stroke-width: 2px;
    fill: transparent;
}
                </style>
            </defs>
            <text class='text1' x='50' y='193'>
               WordPress
            </text>
        </svg>
    </div>

So this should work?  And shouldnt' crop it?

I take it there is no way to use the VW font-size method, as I don't understand it.

Link to comment
Share on other sites

I couldn't get it to work.

I want really to have a CSS that can set the text to be 100% the width of the containing DIV (ie, if it is in a 50% column...

And then one that I can tweak (ie. i fit is  in a full width column, I could set it to say 2/3s width.

Possible?

Link to comment
Share on other sites

Both are possible - SVG images are scalable without distortion.

  • Relative positions and proportions are more important than actual sizes.
  • Determine the width and height of the two text strings - use imagettfbbox() function to get dimensions. (Text1 is going to be about twice the fontsize of text2).
  • Determine the size of the viewBox required to hold them (It helps to set a background color to the whole SVG if experimenting with its size so you can check the fit.) EG...image.png.52f94dfe4fe200ffbdd4c5c86b8e3f2c.png

Setting svg width to either 100% or 66% will give your width requirements above.

Link to comment
Share on other sites

9 minutes ago, simona6 said:

Why does it crop the top off tho?

I don't know, can't test under your conditions.

I tried getting the geomanist font. It seems to be a con!

The Altpo site gives you a "Free download" button then immediately asks you if you will be paying via Twitter or Facebook to continue.

As this is a one-off, I exited.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.